fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  4. #define int long long
  5. #define endl '\n'
  6.  
  7. void solve(){
  8. int n,m;
  9. cin>>n>>m;
  10. cout<<n+m-1<<endl;
  11. int i=1,j=1;
  12. while(i!=n || j!=m){
  13. cout<<i<<" "<<j<<endl;
  14. j++;
  15. if (j==m) break;
  16. cout<<i<<" "<<j<<endl;
  17. i++;
  18.  
  19. }
  20. cout<<n<<" "<<m<<endl;
  21.  
  22. }
  23.  
  24.  
  25. int32_t main(){
  26. fast_io;
  27. int t=1;
  28.  
  29. while(t--) solve();
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0.01s 5288KB
stdin
2 3
stdout
4
1 1
1 2
2 2
2 3