Kingdoms and Quarantine

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

문제

There are two kingdoms AA (with N_1N\_1 cities) and BB (with N_2N\_2 cities), and MM bidirectional roads, each connecting a city from AA and a city from BB, such that there is no more than one road connecting any pair of cities.

The cities in the kingdom AA are enumerated from 11 to N_1N\_1, and the cities in the kingdom BB are enumerated from N_1+1N\_1 + 1 to N_1+N_2N\_1 + N\_2. The roads are enumerated from 11 to MM; the road ii connects two cities a_ia\_i and b_ib\_i, where a_ia\_i and b_ib\_i satisfy 1a_iN_11 \le a\_i \le N\_1 and N_1+1b_iN_1+N_2N\_1 + 1 \le b\_i \le N\_1 + N\_2.

Once upon a time, a dangerous virus appeared in one kingdom, so the Kings decided to close some roads.

Let D_jD\_j be the initial number of roads connecting the city jj with other cities, and d_jd\_j be the number of currently active (not closed) roads connecting the city jj with other cities.

The road xx can be closed if and only if following conditions are met before closing the road:

  • It was not closed before.
  • The numbers d_a_xd\_{a\_x} and D_b_xD\_{b\_x} must have the same parity (both even or both odd).
  • The numbers d_b_xd\_{b\_x} and D_a_xD\_{a\_x} must have the same parity (both even or both odd).

Find the maximum number of roads that can be closed, and then find a sequence of road closing operations such that this maximum is achieved.

입력

The first line of input contains three integers, N_1N\_1, N_2N\_2, and MM: the number of cities in kingdom AA, the number of cities in kingdom BB, and the number of roads, respectively (1N_1,N_2,M30001 \le N\_1, N\_2, M \le 3000, 1MN_1N_21 \le M \le N\_1 \cdot N\_2).

The ii-th of the following MM lines describes the road ii and contains two integers a_ia\_i and b_ib\_i (1a_iN_11 \le a\_i \le N\_1, N_1+1b_iN_1+N_2N\_1 + 1 \le b\_i \le N\_1 + N\_2): the numbers of cities connected by that road. You may assume that, for different ii and jj, a_ia_ja\_i \ne a\_j or b_ib_jb\_i \ne b\_j.

출력

On the first line, print the integer KK: the maximum number of roads that can be closed. On the second line, print KK integers r_ir\_i (1r_iM1 \le r\_i \le M): the numbers of roads to be closed, in the order of closing them.

If there are several optimal answers, print any one of them.

힌트

In the first example, D_1=3D\_1 = 3, D_2=2D\_2 = 2, D_3=1D\_3 = 1, D_4=2D\_4 = 2, D_5=2D\_5 = 2.

Initially, d_1=3d\_1 = 3, d_2=2d\_2 = 2, d_3=1d\_3 = 1, d_4=2d\_4 = 2, d_5=2d\_5 = 2, so we can close the following roads:

  • Road 1 connecting city 1 and city 3.
  • Road 4 connecting city 2 and city 4.
  • Road 5 connecting city 2 and city 5.

Let us close road 1, then 

d_1=2d\_1 = 2, d_2=2d\_2 = 2, d_3=0d\_3 = 0, d_4=2d\_4 = 2, d_5=2d\_5 = 2.

After that, the roads that can be closed are the following:

  • Road 4 connecting city 2 and city 4.
  • Road 5 connecting city 2 and city 5.

Let us close road 4, then

d_1=2d\_1 = 2, d_2=1d\_2 = 1, d_3=0d\_3 = 0, d_4=1d\_4 = 1, d_5=2d\_5 = 2.

Now, we can close only road 2, connecting city 1 and city 4.

After that, d_1=1d\_1 = 1, d_2=1d\_2 = 1, d_3=0d\_3 = 0, d_4=0d\_4 = 0, d_5=2d\_5 = 2.

It can be shown that it is impossible to close more than three roads, so the answer is 33.