#include #include #include #include #include using namespace std; #define LL long long vector > wyn; bool zawiera(pair a, pair b) { if(a.first>=b.first && a.first<=b.second && a.second>=b.first && a.second<=b.second) return 1; return 0; } bool compare(pair a, pair b) { if(a.first==b.first) return a.second > tab, pair co, LL &w) { if(p==k && zawiera(tab[p],co)) { w= tab[p].first; return; } else if(p>=k) { w=-1; return; } LL i=(k-p)/2+p; if(zawiera(tab[i],co)) w=tab[i].first; else if(tab[i].firstco.second || tab[i].second>co.second) szukaj(p,i-1,tab,co,w); else w=tab[i].first; } int main() { LL M, Q; while(scanf("%lld %lld", &M, &Q) && (M!=0 || Q!=0)) { vector klucz(M); map > czy; wyn.clear(); for(int i=0;i temp=czy[klucz[i]]; czy[klucz[i]].push_back(i); for(int x=0;x