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(true){
  13. cout<<i<<" "<<j<<endl;
  14. j++;
  15. if (j==m) break;
  16. cout<<i<<" "<<j<<endl;
  17. i++;
  18. if(i==n) break;
  19.  
  20. }
  21. cout<<n<<" "<<m<<endl;
  22.  
  23. }
  24.  
  25.  
  26. int32_t main(){
  27. fast_io;
  28. int t=1;
  29.  
  30. while(t--) solve();
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 5320KB
stdin
2 1
stdout
2
1 1
1 2
2 1