#include using namespace std; const long TARGET=5e17; struct card{ long surface; long back; }; void rewrite(card& u, card& v){ long a=u.surface; long b=v.surface; long surface=(a+b)/2; u.surface=surface; v.surface=surface; long c=u.back; long d=v.back; long back=(c+d)/2; u.back=back; v.back=back; } long score(const card& u, const card& v){ long temp=max(abs(u.surface-TARGET),abs(u.back-TARGET)); long tmp=max(abs((u.surface+v.surface)/2-TARGET),abs((u.back+v.back)/2-TARGET)); return temp-tmp; } long score(const card& t, const card& u, const card& v){ long temp=max(abs(t.surface-TARGET),abs(t.back-TARGET)); long tmp=max(abs((t.surface+(u.surface+v.surface)/2)/2-TARGET),abs((t.back+(u.back+v.back)/2)/2-TARGET)); return temp-tmp; } int main(){ int n; cin >> n; assert(n==45); vector cards(n); for(int i=0;i> cards[i].surface >> cards[i].back; } vector> V; while(true){ long hiscore=0; int k=0; for(int i=1;ihiscore){ k=i; hiscore=s; } } if(k){ V.push_back(make_pair(1,k+1)); rewrite(cards[0],cards[k]); }else{ break; } if(V.size()==50){ break; } } while(true){ long hiscore=0; int k=0; int l=0; for(int i=1;ihiscore){ k=j; l=i; hiscore=s; } } } if(k>0 && l>0){ V.push_back(make_pair(k+1,l+1)); rewrite(cards[k],cards[l]); if(V.size()==50){ break; } V.push_back(make_pair(1,k+1)); rewrite(cards[0],cards[k]); if(V.size()==50){ break; } }else{ break; } } cout << V.size() << endl; for(pair v:V){ cout << v.first << ' ' << v.second << endl; } return EXIT_SUCCESS; }