struct T
{
int v,next;
}E[N*N];
struct TT
{
int head;
}V[N];
bool used[N];
bool dfs(int u)
{
if(used[u])
return true;
used[u] = true;
for(int i=V[u].head;i!=NULL;i=E[i].next)
if(dfs(E[i].v))
return true;
used[u] = false;
return false;
}
int main()
{
for(int i=1;i<=n;i++)
{
used[i] = true;
for(int j=V[j].head;j!=NULL;j=E[j].next)
if(dfs(E[j].u)); //Have circle
used[i] = false;
}
}