Eulerian Path is a path in graph that visits every edge exactly once. Eulerian Circuit is an Eulerian Path which starts and ends on the same vertex. Your task is to find that their exists the Euler circuit or not.

**Input:**

First line consists of test cases T. First line of every test case consists of 2 integers V and E, denoting the number of vertex and edges. Second line of every test case consists of 2*E spaced integers denoting the direction of edge connected(from - to).

**Output:**

Return the bool value to print 1 if Euler circuit exists else 0.

**Constraints:**

1<=T<=100

1<=V,E<=100

**Example:
Input:**

1

5 6

1 0 0 2 2 1 0 3 3 4 4 0

1

**Explanation:**

One of the Eulerian Circuit starting and ending at 0 is as follows:

0 -> 2 -> 1 -> 0 -> 3 -> 4 -> 0

Author: saksham seth

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

saiujwal13083 | 347 |

isiddhisingh | 252 |

Abhishek_Jadhav | 243 |

_uncle_sam_ | 221 |

c_ocoooo | 217 |

saiujwal13083 | 610 |

SumitSingh27 | 466 |

c_ocoooo | 456 |

rathiarpit29 | 379 |

NaveenKumarNakka | 370 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4931 |

Quandray | 4598 |

Login to report an issue on this page.