/*
Normal graph routine
*/
void dfs(int v, int parent)
{
	visited[v] = 1;

	rep(i, 0, SZ(g[v]))
	{
		if(!visited[g[v][i]])
			dfs(g[v][i], v);
		else if(g[v][i] != parent)
		{
			hasCycle = true;
			return;
		}
	}
}

/*

calling dfs
*/
for(int i=0;i<n;i++)
{
	if(!visited[i])
	{
	 dfs(i, -1);            //->this line why do people start with -1 even after knowing the fact that -1 can't be there
	 if(hasCycle)
		break;
	}
}