Pagini recente » Cod sursa (job #140537) | Cod sursa (job #275749) | Cod sursa (job #1781819) | Cod sursa (job #2769431) | Cod sursa (job #1839833)
#include <cstdio>
#include <cctype>
#define NMax 50000
#define DIM 10000
char buff[DIM];
int poz;
int v[NMax+1];
void Read(int& numar)
{
numar = 0;
while( !isdigit(buff[poz]) )
if(++poz==DIM) fread(buff,1,DIM,stdin),poz=0;
while( isdigit(buff[poz]) )
{
numar = numar*10 + buff[poz] - '0';
if(++poz==DIM) fread(buff,1,DIM,stdin),poz=0;
}
}
int main(){
freopen("bowling.in","r",stdin);
freopen("bowling.out","w",stdout);
int i,j,p,ok,x,next,N,M,T;
Read(T);
while(T--)
{
Read(N);
for(i = 1; i <= N; ++i) Read(v[i]);
while(!v[N]) --N;
for(M = N; M >= 1 && v[M]; --M);
for(i = j = 1; j <= M && !v[j]; ++j);
for(p = j; j <= M && v[j]; ++j);
x = j-p;
if( x%3==1 || x%3==2 ) next = 2;
else next = 1;
i = j;
for(ok = 1; i <= M; )
{
for(j = i; j <= M && !v[j]; ++j);
for(p = j; j <= M && v[j]; ++j);
x = j-p;
if( x%3==1 ) next = 3 - next;
if( x%3==2 && next == 1 ) next = 3 - next;
i = j;
}
x = N-M;
if( x%3 == 1 && next != 1 ) ok = 0;
if( x%3 == 0 && next != 2 ) ok = 0;
if(ok) printf("Nargy\n");
else printf("Fumeanu\n");
}
return 0;
}