Number Of Vertices

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

New meta.

A zigzag cycle in an undirected graph is a sequence of vertices a_0,a_1,,a_k1a\_0, a\_1, \ldots, a\_{k-1}, \uline{not necessarily distinct}, such that for all i:0i<ki: 0 \leq i < k a_ia\_i and a_(i+1)modka\_{(i+1) \mod k} are adjacent in the graph and one of the following holds:

  1. a_(i+k1)modk<a_i,a_i>a_(i+1)modka\_{(i+k-1)\mod k} < a\_i, a\_i > a\_{(i+1) \mod k}
  2. a_(i+k1)modk>a_i,a_i<a_(i+1)modka\_{(i+k-1)\mod k} > a\_i, a\_i < a\_{(i+1) \mod k}

A cycle contains the edge (u,v)(u, v) pp times if there exist exactly pp distinct i:0i<ki: 0 \leq i < k, such that a_i=u,a_(i+1)modk=va\_i = u, a\_{(i+1) \mod k} = v or a_i=v,a_(i+1)modk=ua\_i = v, a\_{(i+1) \mod k} = u

A graph is splittable if there exists a set of zigzag cycles, such that for each edge exactly one cycle contains it 11 time and all the remaining cycles contain it 00 times, i.e. you can split edges of the graph into zigzag cycles.

There is a graph which is initially empty. Process the following types of queries:

  1. Add an edge between vertices uu and vv.
  2. Remove an edge between vertices uu and vv.

After each query print whether the graph is splittable.

입력

The first line contains two integers nn and qq (2n3105,1q31052 \leq n \leq 3 \cdot 10^5, 1 \leq q \leq 3 \cdot 10^5) --- the number of vertices in the graph and the number of queries, respectively.

qq lines follow. ii-th of them contains three integers t,u,vt, u, v (t1,2,1u<vnt \in \\{1, 2\\}, 1 \leq u < v \leq n) --- the type of query and the endpoints of the edge you have to add if t=1t = 1 or remove if t=2t = 2. No query will ask to you to add an already present edge or to delete an absent one.

출력

Print qq lines. ii-th of them should contain 1 if the graph is splittable after the first ii queries and 0 otherwise.

힌트

After processing all the queries one possible set of zigzag cycles is \[1,4,3,5],\[2,6,4,5]\\{\[1,4,3,5], \[2,6,4,5]\\}.