F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Go Deeper

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 4093    Accepted Submission(s): 1306


Problem Description
Here is a procedure's pseudocode:

go(int dep, int n, int m)
begin
output the value of dep.
if dep < m and x[a[dep]] + x[b[dep]] != c[dep] then go(dep + 1, n, m)
end

In this code n is an integer. a, b, c and x are 4 arrays of integers. The index of array always starts from 0. Array a and b consist of non-negative integers smaller than n. Array x consists of only 0 and 1. Array c consists of only 0, 1 and 2. The lengths of array a, b and c are m while the length of array x is n. Given the elements of array a, b, and c, when we call the procedure go(0, n, m) what is the maximal possible value the procedure may output?
 

Input
There are multiple test cases. The first line of input is an integer T (0 < T ¡Ü 100), indicating the number of test cases. Then T test cases follow. Each case starts with a line of 2 integers n and m (0 < n ¡Ü 200, 0 < m ¡Ü 10000). Then m lines of 3 integers follow. The i-th(1 ¡Ü i ¡Ü m) line of them are ai-1 ,bi-1 and ci-1 (0 ¡Ü ai-1, bi-1 < n, 0 ¡Ü ci-1 ¡Ü 2).
 

Output
For each test case, output the result in a single line.
 

Sample Input
3 2 1 0 1 0 2 1 0 0 0 2 2 0 1 0 1 1 2
 

Sample Output
1 1 2
 

Author
CAO, Peng
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 09:14:45, Gzip enabled