#include int aFREE = -1; int c; int p[100002]; int stack[100003]; int priznaky[100004]; int top=0; int presun(int pozice) { if (p[p[pozice]] != aFREE) { if (priznaky[p[pozice]]) { while(top>0) { p[stack[--top]]=aFREE; } return 1; } else { priznaky[p[pozice]]=1; stack[top++]=p[pozice]; return 1+presun(p[pozice]); } } else { p[pozice]=aFREE; return 1; } } int main(void) { int s; int sektoru=0; scanf("%d%d", &c, &s); while (c!=0 && s!=0) { int start = 1; for (int i=0; i