ZhenlongDai/ACPR huggingface dataset:
Problem: p03386
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,k = map(int,input().split())
t = []

for i in range(a,a+k):
    t.append(i)
for i in range(b-k+1,b+1):
    t.append(i)

t = list(set(t))
t.sort()

for i in range(len(t)):
    print(t[i])

Failing test case input:
5 14 110

Expected output:
5
6
7
8
9
10
11
12
13
14


Actual output:
-95
-94
-93
-92
-91
-90
-89
-88
-87
-86
-85
-84
-83
-82
-81
-80
-79
-78
-77
-76
-75
-74
-73
-72
-71
-70
-69
-68
-67
-66
-65
-64
-63
-62
-61
-60
-59
-58
-57
-56
-55
-54
-53
-52
-51
-50
-49
-48
-47
-46
-45
-44
-43
-42
-41
-40
-39
-38
-37
-36
-35
-34
-33
-32
-31
-30
-29
-28
-27
-26
-25
-24
-23
-22
-21
-20
-19
-18
-17
-16
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114


Fixed submission (verdict: Accepted):
a,b,k = map(int,input().split())
t = []

for i in range(a,a+k):
    if i <= b:
        t.append(i)
for i in range(b-k+1,b+1):
    if i >= a:
        t.append(i)

t = list(set(t))
t.sort()

for i in range(len(t)):
    print(t[i])

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k = map(int, input().split())

for i in range(a, b+1):
    if i <= a+k or b-k < i:
        print(i)


Failing test case input:
0 14 3

Expected output:
0
1
2
12
13
14


Actual output:
0
1
2
3
12
13
14


Fixed submission (verdict: Accepted):
a, b, k = map(int, input().split())

for i in range(a, min(b+1, a+k)):
    print(i)
for i in range(max(b-k+1, a+k), b+1):
    print(i)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k = map(int, input().split())
if a+k < b-k:
    for i in range(a,a+k):print(i)
    for j in range(b-k+1,b+1):print(j)
else:
    for i in range(a,b+1):print(i)

Failing test case input:
3 23 010

Expected output:
3
4
5
6
7
8
9
10
11
12
14
15
16
17
18
19
20
21
22
23


Actual output:
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Fixed submission (verdict: Accepted):
a,b,k = map(int, input().split())
if a+k < b-k+1:
    for i in range(a,a+k):print(i)
    for j in range(b-k+1,b+1):print(j)
else:
    for i in range(a,b+1):print(i)
Problem: p03386
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, K = input().split(' ')
A = int(A)
B = int(B)
K = int(K)
N = []
if B-A>K:
  for i in range(A, A+K):
    print(i)
  for i in range(B-K, B+1):
    print(i)
else:
  for i in range(A, B+1):
    if i < A + K:
      print(i)
    elif i > B-K:
      print(i)

Failing test case input:
0 8 6

Expected output:
0
1
2
3
4
5
6
7
8


Actual output:
0
1
2
3
4
5
2
3
4
5
6
7
8


Fixed submission (verdict: Accepted):
A, B, K = input().split(' ')
A = int(A)
B = int(B)
K = int(K)
N = []
if B-A>K:
  for i in range(A, A+K):
    print(i)
    N.append(i)
  for i in range(B-K+1, B+1):
    if not i in N:
      print(i)

else:
  for i in range(A, B+1):
    if i < A + K:
      print(i)
    elif i > B-K:
      print(i)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = map(int, input().split())
cnt = 0
for i in range(a, a+c):
    print(i)
    cnt = i
for i in range(b-c+1, b+1):
    if i > cnt:
        print(i)


Failing test case input:
-1 7 011

Expected output:
-1
0
1
2
3
4
5
6
7


Actual output:
-1
0
1
2
3
4
5
6
7
8
9


Fixed submission (verdict: Accepted):
a, b, c = map(int, input().split())
cnt = 0
for i in range(a, a+c):
    if i <= b:
        print(i)
    cnt = i
for i in range(b-c+1, b+1):
    if i > cnt and i >= a:
        print(i)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k = map(int,input().split())
if (b - a) <= 2*k  :
    for i in range(a,b+1):
        print('{}'.format(i))
else:    
    for i in range(k):
        print('{}'.format(a+i))
    for i in range(1,k+1):
        print('{}'.format(b+i-k))
        

Failing test case input:
2 4 001

Expected output:
2
4


Actual output:
2
3
4


Fixed submission (verdict: Accepted):
a, b, k = map(int,input().split())
if (b - a) < 2*k  :
    for i in range(a,b+1):
        print('{}'.format(i))
else:    
    for i in range(k):
        print('{}'.format(a+i))
    for i in range(1,k+1):
        print('{}'.format(b+i-k))

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, K = map(int, input().split())

m  = min(A+K+1, B+1)
for i in range(A, m):
    print(i)
n = max(A+K+1, B-K, B)
for j in range(n, B+1):
    print(j)

Failing test case input:
1 22 1

Expected output:
1
22


Actual output:
1
2
22


Fixed submission (verdict: Accepted):
A, B, K = map(int, input().split())

m  = min(A+K, B+1)
for i in range(A, m):
    print(i)
n = max(A+K, B-K+1)
for j in range(n, B+1):
    print(j)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c = map(int,input().split())

if b-a+1 > 2*c:
    for i in range(a,a+c):
        print(i)
    for i in range(b-c+1,b):
        print(i)
else:
    for i in range(a,b+1):
        print(i)


Failing test case input:
2 17 6

Expected output:
2
3
4
5
6
7
12
13
14
15
16
17


Actual output:
2
3
4
5
6
7
12
13
14
15
16


Fixed submission (verdict: Accepted):
a,b,c = map(int,input().split())

if b-a+1 > 2*c:
    for i in range(a,a+c):
        print(i)
    for i in range(b-c+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)
Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, K = map(int, input().split())
ans = []
for i in range(A,A+K):
    if B <= i:
        break
    ans.append(i)
for i in range(B-K+1,B+1):
    if i <= A:
        continue
    ans.append(i)
ans.sort()
ans2 = set(ans)
for i in ans2:
    print(i)

Failing test case input:
6 6 110

Expected output:
6


Actual output:

Fixed submission (verdict: Accepted):
A, B, K = map(int, input().split())
ans = []
if A == B:
    print(A)
    exit()
for i in range(A,A+K):
    if B <= i:
        break
    ans.append(i)
for i in range(B-K+1,B+1):
    if i <= A:
        continue
    ans.append(i)
ans2 = set(ans)
ans3 = list(ans2)
ans3.sort()
for i in ans3:
    print(i)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c=map(int,input().split())
l=set()
for i in range(a,a+c):
    if i!=b:l.add(str(i))
    else:break
for i in range(max(b-c+1,a),b+1):
    l.add(str(i))    
print("\n".join(sorted(list(l))))

Failing test case input:
3 13 2

Expected output:
3
4
12
13


Actual output:
12
13
3
4


Fixed submission (verdict: Accepted):
a,b,c=map(int,input().split())
l=set()
for i in range(a,a+c):
    if i!=b:l.add(i)
    else:break
for i in range(max(b-c+1,a),b+1):
        l.add(i)
print("\n".join(map(str,sorted(list(l)))))

Problem: p03386
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if (a+c-1)>(b-c-1):
  for i in range(c):
    print(a+i)
  for i in range(c):
    print(b-c+1+i)
else:
  for i in range(a,b+1):
    print(i)

Failing test case input:
4 9 2

Expected output:
4
5
8
9


Actual output:
4
5
6
7
8
9


Fixed submission (verdict: Accepted):
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if (a+c-1)<(b-c+1):
  for i in range(c):
    print(a+i)
  for i in range(c):
    print(b-c+1+i)
else:
  for i in range(a,b+1):
    print(i)
Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import time
import re
import math

def main():
    A,B,K = map(int,input().split())
    ls=[]
    for a in range(K):
        ls.append(A + a)
        ls.append(B - K +1+ a)
    ls=set(ls)
    ls=sorted(ls)
    for a in ls:
        print(a)
main()

Failing test case input:
2 6 110

Expected output:
2
3
4
5
6


Actual output:
-103
-102
-101
-100
-99
-98
-97
-96
-95
-94
-93
-92
-91
-90
-89
-88
-87
-86
-85
-84
-83
-82
-81
-80
-79
-78
-77
-76
-75
-74
-73
-72
-71
-70
-69
-68
-67
-66
-65
-64
-63
-62
-61
-60
-59
-58
-57
-56
-55
-54
-53
-52
-51
-50
-49
-48
-47
-46
-45
-44
-43
-42
-41
-40
-39
-38
-37
-36
-35
-34
-33
-32
-31
-30
-29
-28
-27
-26
-25
-24
-23
-22
-21
-20
-19
-18
-17
-16
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111


Fixed submission (verdict: Accepted):

import time
import re
import math

def main():
    A,B,K = map(int,input().split())
    ls=[]
    for a in range(K):
        ls.append(A + a)
        ls.append(B - K +1+ a)
    ls=set(ls)
    ls=sorted(ls)
    for a in ls:
        if (a>=A and a<=B):print(a)
main()

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k = map(int,input().split())
data = range(a,b+1)
b_a = b-a
if b_a <= k*2:
  for num in data:
    print(num)
else:
  min_k = data[:k]
  max_k = data[-k:]
  for num in min_k:
    print(num)
  for num in max_k:
    print(num)

Failing test case input:
3 23 010

Expected output:
3
4
5
6
7
8
9
10
11
12
14
15
16
17
18
19
20
21
22
23


Actual output:
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Fixed submission (verdict: Accepted):
a,b,k = map(int,input().split())
data = range(a,b+1)
b_a = b-a
if b_a < k*2:
  for num in data:
    print(num)
else:
  min_k = data[:k]
  max_k = data[-k:]
  for num in min_k:
    print(num)
  for num in max_k:
    print(num)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,K = [int(i) for i in input().rstrip().split()]

if K <= (B-A+1)/2:
  print(*( list(range(A,K+1)) + list(range(B-K+1,B+1)) ),sep="\n")
else:
  print(*list(range(A,B+1)),sep="\n")


Failing test case input:
4 35 001

Expected output:
4
35


Actual output:
35


Fixed submission (verdict: Accepted):
A,B,K = [int(i) for i in input().rstrip().split()]

if K <= (B-A+1)/2:
  print(*( list(range(A,A+K)) + list(range(B-K+1,B+1)) ),sep="\n")
else:
  print(*list(range(A,B+1)),sep="\n")
Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k = (int(x) for x in input().split())
if b - a -1<= k:
    for i in range(a,b+1):
        print(i)
else :
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)

Failing test case input:
0 8 6

Expected output:
0
1
2
3
4
5
6
7
8


Actual output:
0
1
2
3
4
5
3
4
5
6
7
8


Fixed submission (verdict: Accepted):
a,b,k = (int(x) for x in input().split())
if (b - a+1)<= k*2:
    for i in range(a,b+1):
        print(i)
else :
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, K = map(int, input().split())

if B - A > 2 * K:
    for i in range(A, A + K):
        print(i)
    for i in range(B - K + 1, B + 1):
        print(i)
else:
    for i in range(A, B + 1):
        print(i)


Failing test case input:
1 13 6

Expected output:
1
2
3
4
5
6
8
9
10
11
12
13


Actual output:
1
2
3
4
5
6
7
8
9
10
11
12
13


Fixed submission (verdict: Accepted):
A, B, K = map(int, input().split())

if B - A + 1 > 2 * K:
    for i in range(A, A + K):
        print(i)
    for i in range(B - K + 1, B + 1):
        print(i)
else:
    for i in range(A, B + 1):
        print(i)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k = list(map(int,input().split()))
l = [i for i in range(a,a+k) if a<= i and b>=i]+[i for i in range(b, b-k, -1) if a<= i and b>=i]
ll = set(sorted(l))

for i in ll:
    print(i)

Failing test case input:
3 8 2

Expected output:
3
4
7
8

Actual output:
8
3
4
7


Fixed submission (verdict: Accepted):
a,b,k = list(map(int,input().split()))
l = [i for i in range(a,a+k) if a<= i and b>=i]+[i for i in range(b, b-k, -1) if a<= i and b>=i]
ll = sorted(set(l))

for i in ll:
    print(i)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c = map(int,input().split())
l = []
for i in range(c):
  l.append(a+i)
  l.append(b-c)
l = set(l)
for i in l:
  print(i)

Failing test case input:
7 35 011

Expected output:
7
8
9
10
11
12
13
14
15
16
17
25
26
27
28
29
30
31
32
33
34
35


Actual output:
7
8
9
10
11
12
13
14
15
16
17
24


Fixed submission (verdict: Accepted):
a,b,c = map(int,input().split())
l = []
for i in range(c):
  d = a+i
  e = b-i
  if d<=b and a<=e:
    l.append(a+i)
    l.append(b-i)
l = sorted(set(l))
for i in l:
  print(i)

Problem: p03386
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
a, b, k = map(int, input().split())
l = [i for i in range(a, b+1)]

for i in set(l[-k:] +l[:k]):
    print(i)

Failing test case input:
-2 14 5

Expected output:
-2
-1
0
1
2
10
11
12
13
14


Actual output:
0
1
2
10
11
12
13
14
-1
-2


Fixed submission (verdict: Accepted):
a, b, k = map(int, input().split())
r = range(a, b+1)

for i in (sorted(set(r[:k]) | set(r[-k:]))):
    print(i)
Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split(' '))

ans = [-1] * N

for m in range(M):
    s, c = map(int, input().split(' '))
    if s == 1 and c == 0:
        if N == 1:
            print(0)
        else:
            print(-1)
        exit(0)
    if ans[s - 1] != -1 and ans[s - 1] != c:
        print(-1)
        exit(0)
    ans[s - 1] = c


if ans[0] == -1:
    ans[0] = 1

if ans[0] == 0 and N != 1:
    print(-1)
    exit(0)

for i in range(1, N):
    if ans[i] == -1:
        ans[i] = 0

ANS = int(''.join(map(str, ans)))

print(ANS)

Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
N, M = map(int, input().split(' '))

ans = [-1] * N

for m in range(M):
    s, c = map(int, input().split(' '))
    if s == 1 and c == 0:
        if N == 1:
            print(0)
        else:
            print(-1)
        exit(0)
    if ans[s - 1] != -1 and ans[s - 1] != c:
        print(-1)
        exit(0)
    ans[s - 1] = c


if ans[0] == -1:
    if N == 1:
        print(0)
        exit(0)
    ans[0] = 1

if ans[0] == 0 and N != 1:
    print(-1)
    exit(0)

for i in range(1, N):
    if ans[i] == -1:
        ans[i] = 0

ANS = int(''.join(map(str, ans)))

print(ANS)

Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())

l = []

for i in range(m):
  l.append(list(map(int, input().split())))

ans = -1
for i in range(10 ** (n - 1), 10 ** n):
  s = str(i)
  result = True
  for x in l:
    if not s[x[0] - 1] == str(x[1]):
      result = False
      break
  if result:
    ans = i
    break

print(ans)



Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())

l = []

for i in range(m):
  l.append(list(map(int, input().split())))

ans = -1
if n == 1:
  start = 0
else:
  start = 10 ** (n - 1)
for i in range(start, 10 ** n):
  s = str(i)
  result = True
  for x in l:
    if not s[x[0] - 1] == str(x[1]):
      result = False
      break
  if result:
    ans = i
    break

print(ans)
Problem: p02761
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, M = map(int, input().split())

ans = []
neg = 0
for n in range(N):
  ans.append(-1)

for m in range(M):
  s, c = map(int, input().split())
  if ans[s-1] == -1:
    ans[s-1] = c
  elif ans[s-1] == c:
    pass
  else:
    neg = -1
    break

if ans[0] == 0:
  neg = -1

for j in range(len(ans)):
  if ans[j] == -1:
    ans[j] = 0

if neg == -1:
  print(neg)
else:
  print("".join([str(i) for i in ans]))

Failing test case input:
3 1
0 4
1 1

Expected output:
104


Actual output:
004


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())

ans = []
neg = 0
for n in range(N):
  ans.append(-1)

for m in range(M):
  s, c = map(int, input().split())
  if ans[s-1] == -1:
    ans[s-1] = c
  elif ans[s-1] == c:
    pass
  else:
    neg = -1
    break

if ans[0] == 0 and N != 1:
  neg = -1

for j in range(len(ans)):
  if ans[j] == -1:
    ans[j] = 0

if N == 1:
  pass

elif ans[0] == 0:
  ans[0] = 1

if neg == -1:
  print(neg)
else:
  print("".join([str(i) for i in ans]))

Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = (int(num) for num in input().split())
ans = ["empty"] * n
isPossible = True
for _ in range(m):
    s,c = (int(num) for num in input().split())
    idx = s - 1
    if ans[idx] == "empty" or ans[idx] == c:
        ans[idx] = c
    else:
        isPossible = False
if n != 0 and ans[0] == 0:
    isPossible = False
    
ans_str = ""
    
if isPossible:
    for num in ans:
        if num == "empty":
            ans_str += "0"
        else:
            ans_str += str(num)
else:
    ans_str = "-1"
    
print(ans_str)

Failing test case input:
3 1
0 0
2 0

Expected output:
100


Actual output:
000


Fixed submission (verdict: Accepted):
n,m = (int(num) for num in input().split())
ans = ["empty"] * n
isPossible = True
for _ in range(m):
    s,c = (int(num) for num in input().split())
    idx = s - 1
    if ans[idx] == "empty" or ans[idx] == c:
        ans[idx] = c
    else:
        isPossible = False
if n != 1 and ans[0] == 0:
    isPossible = False
    
ans_str = ""
    
if isPossible:
    for i in range(len(ans)):
        num = ans[i]
        if num == "empty":
            if i == 0 and n != 1:
                ans_str += "1"
            else:
                ans_str += "0"
        else:
            ans_str += str(num)
else:
    ans_str = "-1"
    
print(ans_str)
Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
a=[-1]*n
ans=1
for i in range(m):
  if a[sc[i][0]-1]==-1:
    a[sc[i][0]-1]=sc[i][1]
  else:
    if a[sc[i][0]-1]!=sc[i][1]:
      ans=0
      break
if a[0]==0:
  ans=0
flag=0
if a[0]==-1 and n==1:
  flag=1
ll=""
for j in range(n):
  if a[j]==-1:
    a[j]=0
  ll+=str(a[j])
 
if ans==0:
  print(-1)
else:
  if n!=len(str(int(ll))):
    print(int(ll)+10**(n-1))
  else:
    if flag==1:
      print(9)
    else:
      print(int(ll))

Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
9


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
a=[-1]*n
ans=1
for i in range(m):
  if a[sc[i][0]-1]==-1:
    a[sc[i][0]-1]=sc[i][1]
  else:
    if a[sc[i][0]-1]!=sc[i][1]:
      ans=0
      break
if a[0]==0 and n>=2:
  ans=0
ll=""
for j in range(n):
  if a[j]==-1:
    a[j]=0
  ll+=str(a[j])
  
if ans==0:
  print(-1)
else:
  if n!=len(str(int(ll))):
    print(int(ll)+10**(n-1))
  else:
    print(int(ll))

Problem: p02761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M = list(map(int,input().split()))
ans = [-1 for i in range(N)]

if M == 0:
  ans[0] = str(1)
  for i in range(1,N):
    ans[i] = str(0)
  print("".join(ans))
  exit()

for i in range(M):
  S,C = list(map(int,input().split()))
  if N != 1 and C == 0 and S == 1:
    print('-1')
    exit()
  if ans[S-1] == C:
    continue
  elif ans[S-1] != -1:
    print('-1')
    exit()
  ans[S-1] = C
  
for i in range(N):
  if ans[i] == -1:
    ans[i] = str(0)
  ans[i] = str(ans[i])

print("".join(ans))

Failing test case input:
3 1
0 0
1 0

Expected output:
100


Actual output:
000


Fixed submission (verdict: Accepted):
N,M = list(map(int,input().split()))
ans = [-1 for i in range(N)]

if N == 1 and M == 0:
  print(0)
  exit()
if M == 0:
  ans[0] = str(1)
  for i in range(1,N):
    ans[i] = str(0)
  print("".join(ans))
  exit()

for i in range(M):
  S,C = list(map(int,input().split()))
  if N != 1 and C == 0 and S == 1:
    print('-1')
    exit()
  if ans[S-1] == C:
    continue
  elif ans[S-1] != -1:
    print('-1')
    exit()
  ans[S-1] = C
  
for i in range(N):
  if ans[i] == -1:
    if i == 0:
      ans[i] = 1
    else:
      ans[i] = str(0)
  ans[i] = str(ans[i])

print("".join(ans))
Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int, input().split())
sets = []
for i in range(M):
    s,c = input().split()
    sets.append((s,c))
for n in range(10**(N-1), 10**N):
    for s,c in sets:
        if not str(n)[int(s)-1] == c:
            break
        else:
            print(n)
    break
else:
    print(-1)

Failing test case input:
3 1
0 4
1 1

Expected output:
104


Actual output:

Fixed submission (verdict: Accepted):
N,M = map(int, input().split())
 
sets = []
for i in range(M):
  s,c = input().split()
  sets.append((s,c))
 
start = 0
if N != 1:
  start = 10**(N-1)
 
for n in range(start,10**N):
  for s,c in sets:
    if str(n)[int(s)-1] == c:
      continue
    else:
      break
  else:
    print(n)
    break
else:
  print(-1)

Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n, m = map(int,input().split())

l = [[],[],[]]
f = 1

for i in range(m):
    keta , num = map(int,input().split())
    l[keta-1].append(num)



for i in range(1010):
    si = str(i)
    if len(si) != n:
        continue
    for j in range(3):
        for k in l[j]:
            
            if si[j] == str(k):
                
                f = 0
            else:
                f = 1
                break
        if f:
            break
    if f == 0:
        print(si)
        exit()

print(-1)

Failing test case input:
3 2
0 0
-1 0

Expected output:
100


Actual output:
-1


Fixed submission (verdict: Accepted):

n, m = map(int,input().split())

l = []
f = 0

for i in range(m):
    l.append(list(map(int,input().split())))



for i in range(1000):
    si = str(i)
    if len(si) == n:
        for j in range(m):
            
            if si[l[j][0]-1] == str(l[j][1]):
                
                f = 0
            else:
                f = 1
                break
    else:
        continue
    if f == 0:
        print(si)
        exit()

print(-1)

Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]
temp = [-1] * n
sc.sort(key=lambda x: x[0])
ans = []
c = 1
print(sc)
for i in sc:
    print(temp,i)
    if temp[i[0]-1] != -1 and temp[i[0]-1] != i[1]:
        print(-1)
        exit()
    temp[i[0]-1] = i[1]
if temp[0] == -1:
    ans = '1'
else:
    ans = str(temp[0])
if ans == '0':
    print(-1)
    exit()
for i in temp[1:]:
    if i == -1:
        ans += '0'
    else:
        ans += str(i)
print(ans)

Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
[]
1


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]
temp = [-1] * n
ans = -1

for i in sc:
    if temp[i[0]-1] != -1 and temp[i[0]-1] != i[1]:
        print(-1)
        exit()
    temp[i[0]-1] = i[1]

if n == 1:
    mini = 0
    maxi = 10
if n == 2:
    mini = 10
    maxi = 100
if n == 3:
    mini = 100
    maxi = 1000

for i in range(mini,maxi):
    s = str(i)
    ok = True
    for j in sc:
        if s[j[0]-1] != str(j[1]):
            ok = False
    if ok:
        ans = i
        print(ans)
        exit()

print(ans)
Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int,input().split())
t = [0 for i in range(n)]
b = ""
a = False
for i in range(m):
    s,c = map(int,input().split())
    if t[s-1] != 0 and c == 0:
        a=True
    elif n != 1 and s == 1 and c == 0:
        a=True 
    elif t[s-1] == 0 or t[s-1] == c:
        t[s-1] = c
    else:
        a=True
for i in range(n):
    b += str(t[i])
if a:
    print(-1)
elif n > 1 and b[0] == 0:
    b[0] == '1'
    print(b)
else:
    print(b)

Failing test case input:
3 0
2 0
2 3

Expected output:
100


Actual output:
000


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
t = [0 for i in range(n)]
e = [True for i in range(n)]
b = ""
a = False
for i in range(m):
    s,c = map(int,input().split())
    if e[s-1]:
        if s == 1 and c == 0:
            a = True
            if n == 1:
                print(0)
                exit()
        else:
            t[s-1] = c
            e[s-1] = False
    else:
        if t[s-1] != c:
            a = True
for i in range(n):
    b += str(t[i])
if a:
    print(-1)
elif n > 1 and b[0] == '0':
    print(str(1)+b[1:3])
else:
    print(b)

Problem: p02761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
[N,M]=[int(i) for i in input().split()]
lis=[-1 for i in range(N)]
flg=0
for m in range(M):
  [s,c]=[int(i) for i in input().split()]
  if lis[s-1]==-1 or lis[s-1]==c:
    lis[s-1]=c
  else:
    flg=1
    break
x=""
if flg==1:
  print("-1")
else:
  for i in range(len(lis)):
    if i==0 and lis[i]==0 and len(lis)!=1:
      print("-1")
      break
    if lis[i]==-1:
      if flg==0 and i==0:
        x+="1"
        flg=2
      else:
        x+="0"
    else:
      x+=str(lis[i])
      flg="2"
    if i==len(lis)-1:print(x)

Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
[N,M]=[int(i) for i in input().split()]
lis=[-1 for i in range(N)]
flg=0
for m in range(M):
  [s,c]=[int(i) for i in input().split()]
  if lis[s-1]==-1 or lis[s-1]==c:
    lis[s-1]=c
  else:
    flg=1
    break
x=""
if flg==1:
  print("-1")
else:
  for i in range(len(lis)):
    if i==0 and lis[i]==0 and len(lis)!=1:
      print("-1")
      break
    if lis[i]==-1:
      if flg==0 and i==0 and len(lis)!=1:
        x+="1"
        flg=2
      else:
        x+="0"
    else:
      x+=str(lis[i])
      flg=2
    if i==len(lis)-1:print(x)
Problem: p02761
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, m = map(int, input().split())
ans = ['t'] * n

for _ in range(m):
    s, c = map(int, input().split())
    if ans[s-1] =='t' or ans[s-1] == str(c):
        ans[s-1]= str(c)
    else:
        print(-1)
        exit(0)
ans = ''.join(ans).replace('t', str(0))
ans = int(ans)
l = str(ans)
if l != n:
    print(-1)
else:
    print(ans)
    

Failing test case input:
3 0
2 1
2 -1

Expected output:
100


Actual output:
-1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
ans = ['t'] * n

for _ in range(m):
    s, c = map(int, input().split())
    if ans[s-1] =='t' or ans[s-1] == str(c):
        ans[s-1]= str(c)
    else:
        print(-1)
        exit(0)
if ans[0] == 't' and n >1:
    ans[0]=str(1)

ans = ''.join(ans).replace('t', str(0))
ans = int(ans)
l = str(ans)
if len(l) != n:
    print(-1)
else:
    print(ans)

Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = list(map(int,input().split()))
A = ["x"] * N
if M == 0:
    if N == 1:
        print(0)
        exit()
    else:
        print("-1")
        exit()
for i in range(M):
    B = input().split()
    if A[int(B[0])-1] == B[1]:
        pass
    elif A[int(B[0])-1] == "x":
        A[int(B[0])-1] = B[1]
    else:
        print("-1")
        exit()
A = "".join(A)
A = A.replace("x","0")
B = int(A)
if A == str(B):
    print(B)
else:
    if A[0] == "0" and len(A) - len(str(B)) == 1:
        print("1" + str(B))
    else:
        print("-1")

Failing test case input:
3 1
2 0
1 7

Expected output:
100


Actual output:
-1


Fixed submission (verdict: Accepted):
A = []
N,M = list(map(int,input().split()))
if M == 0:
    if N == 1:
        print(0)
        exit()
    else:
        print("1" + "0"*(N-1))
        exit()
for i in range(M):
    A.append(list(input().split()))
for i in range(10 ** N):
    str_i = str(i)
    try:
        if N == len(str_i):
            for j,k in A:
                if str_i[int(j)-1] == k:
                    pass
                else:
                    break
            if str_i[int(j)-1] == k:
                print(i)
                exit()
    except IndexError:
        print("-1")
        exit()
print("-1")
Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
L = [-1]*n
for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if s == 0 and c == 0:
        print(-1)
        exit()
    if L[s] != -1 and L[s] != c:
        print(-1)
        exit()
    L[s] = c


ans = ''
for i in range(n):
    if L[i] == -1:
        if i == 0:
            ans += '1'
        else:
            ans += '0'
    else:
        ans += str(L[i])
print(ans)

Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
L = [-1]*n

if m == 0 and n == 1:
    print(0)
    exit()

for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if s == 0 and c == 0:
        if n != 1:
            print(-1)
            exit()
        else:
            L[s] = c
    if L[s] != -1 and L[s] != c:
        print(-1)
        exit()
    L[s] = c


ans = ''
for i in range(n):
    if L[i] == -1:
        if i == 0:
            ans += '1'
        else:
            ans += '0'
    else:
        ans += str(L[i])
print(ans)

Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
sc_list = [list(input().split()) for _ in range(m)]
for i in range(10**(n-1), 10**n):
    flag = True
    s = str(i)
    for sc in sc_list:
        if s[int(sc[0])-1] != sc[1]: 
            flag = False
            break
    if flag:
        print(i)
        exit()
print(-1)

Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
sc_list = [list(input().split()) for _ in range(m)]
ans = -1
for i in range(10**n):
    if len(str(i)) != n:
        continue
    else:
        count = 0
        s = str(i)
        for sc in sc_list:
            if s[int(sc[0])-1] == sc[1]: 
                count += 1
        if count == m:
            ans = i
            break
print(ans)

Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = list(map(int, input().split()))

num = [-1]
for _ in range(N - 1):
	num += [-1]

for _ in range(M):
  s, c = list(map(int, input().split()))
  if num[s - 1] != -1 and num[s - 1] != c:
    print('-1')
    exit()
  num[s - 1] = c

if num[0] == -1:
  num[0] = 1

print(''.join(map(str, map(lambda x: 0 if x == -1 else x, num))))

Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
N, M = list(map(int, input().split()))

num = [-1]
for _ in range(N - 1):
  num += [-1]

for _ in range(M):
  s, c = list(map(int, input().split()))
  if (s == 1 and c == 0 and N != 1) or (num[s - 1] != -1 and num[s - 1] != c):
    print('-1')
    exit()
  num[s - 1] = c

if num[0] == -1:
  if len(num) == 1:
    print('0')
    exit()
  num[0] = 1

print(''.join(map(str, map(lambda x: 0 if x == -1 else x, num))))
Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
i = 0
l = [-1]*N
t = 0
while i<M:
    s,c = map(int,input().split())
    if s == 1 and c == 0:
        t = -1
    elif l[s-1] == -1 or l[s-1] == c:
        l[s-1] = c  
    else:
        t = -1 
    i+=1

for i in range(0,N):
    if l[i]==-1:
        l[i]=0
    i+=1

if t == 0:
    for i in range(0,N):
        t += l[i]*(10**(N-i-1))
        i+=1

print(t)

Failing test case input:
3 1
0 4
1 1

Expected output:
104


Actual output:
4


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
i = 0
l = [-1]*N
t = 0
while i<M:
    s,c = map(int,input().split())
    if N>1 and s == 1 and c == 0:
        t = -1
    elif l[s-1] == -1 or l[s-1] == c:
        l[s-1] = c  
    else:
        t = -1 
    i+=1

if N>1 and l[0] == -1:
    l[0] = 1
elif l[0] == -1:
    l[0] = 0

for i in range(0,N):
    if l[i]==-1:
        l[i]=0
    i+=1

if t == 0:
    for i in range(0,N):
        t += l[i]*(10**(N-i-1))
        i+=1

print(t)

Problem: p02761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
N,M = map(int,input().split())

ans = [0] * N
ans[0] = 1
flag = [True] * N


for i in range(M):

    s,c = map(int,input().split())
    s -= 1

    if flag[s]:
        ans[s] = c
        flag[s] = False

    elif ans[s] != c:
        print (-1)
        sys.exit()

if ans[0] == 0:
    print (-1)
    sys.exit()
print ("".join(map(str,ans)))


Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
N,M = map(int,input().split())

ans = [0] * N
if N != 1:
    ans[0] = 1
flag = [True] * N


for i in range(M):

    s,c = map(int,input().split())
    s -= 1

    if flag[s]:
        ans[s] = c
        flag[s] = False

    elif ans[s] != c:
        print (-1)
        sys.exit()

if len(ans) != 1 and ans[0] == 0:
    print (-1)
    sys.exit()
print ("".join(map(str,ans)))

Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
sc = [list(map(int, input().split()))for i in range(m)]

ans = -1
for i in range(1, 1000):
    if len(str(i)) != n:
        continue
    for s, c in sc:
        if str(i)[s-1] != str(c):
            break
    else:
        ans = i
        break
print(ans)


Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
sc = [list(map(int, input().split()))for i in range(m)]

ans = -1
for i in range(1000):
    if len(str(i)) != n:
        continue
    for s, c in sc:
        if str(i)[s-1] != str(c):
            break
    else:
        ans = i
        break
print(ans)
Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
scs = []
for i in range(m):
    scs.append(list(map(int, input().split())))
    
def set_number(scs):
    number = [-1] * n
    for sc in scs:
        if number[sc[0] - 1] == -1:
            number[sc[0] - 1] = sc[1]
        elif number[sc[0] - 1] != sc[1]:
            return None
    return number
  
def guess_number(number):
    if number is None:
        return -1

    if number[0] == 0:
        return -1
    
    guess = 0
    for i in range(n):
        if i == 0 and  number[i] == 0:
            guess += (10 ** (n - i - 1))
        else:
            guess += number[i] * (10 ** (n - i - 1))

    return guess
  
number = set_number(scs)
print(guess_number(number))

Failing test case input:
3 0
1 1
0 1

Expected output:
100


Actual output:
-111


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
scs = []
for i in range(m):
    scs.append(list(map(int, input().split())))
    
def set_number(scs):
    number = [-1] * n
    for sc in scs:
        if number[sc[0] - 1] == -1:
            number[sc[0] - 1] = sc[1]
        elif number[sc[0] - 1] != sc[1]:
            return None
    return number
  
def guess_number(number):
    if number is None:
        return -1

    if number[0] == 0 and n > 1:
        return -1
    
    guess = 0
    for i in range(n):
        if i == 0 and  number[i] == -1 and n == 1:
            return 0
        elif i == 0 and  number[i] == -1:
            guess += (10 ** (n - i - 1))
        elif number[i] != -1:
            guess += number[i] * (10 ** (n - i - 1))

    return guess

number = set_number(scs)
print(guess_number(number))

Problem: p02761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
ans =[0]*n
flag = False
if m == 0:
    ans_1 = [0]*n
    if n != 1:
        ans_1[0] = 1
        ans_2 = "".join([str(x) for x in ans_1])
        print(ans_2)
    else:
        print(0)

else:
    for i in range(m):
        for j in range(m):
            if sc[i][0] == sc[j][0] and sc[i][1] != sc[j][1]:
                flag = True

    for i in range(m):
        ans[sc[i][0]-1] = sc[i][1]

    if flag or ans[0] == 0:
        print(-1)
    else:
        
        ans_3 = "".join([str(x) for x in ans])
        print(ans_3)

Failing test case input:
3 2
0 0
0 0

Expected output:
100


Actual output:
-1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(m)]

flag = True

if n == 1 and m == 0:
    print(0)
elif n == 1 and m != 0:
    if len(set(sc)) != 1:
        print(-1)
    else:
        print(sc[0][1])
        
        
elif n > 1 and m == 0:
    print(10**(n-1))
    
elif n > 1 and m != 0:
    for i in range(10**(n-1), 10**n):
        i_str = str(i)
        i_list = list(i_str)
        for item in set(sc):
            if i_list[item[0]-1] != str(item[1]):
                break
        else:
            print(i)
            flag = False
            break
    if flag:
        print(-1)
Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n, m = map(int, input().split())
    ans = -1
    lst = [None]*m
    for i in range(m):
        s, c = map(int, input().split())
        lst[i] = [s, c]
    for i in range(1, 1000):
        f = True
        if len(str(i)) != n:
            f = False
            continue
        for v in lst:
            if str(i)[v[0]-1] != str(v[1]):
                f = False
        if f:
            ans = i
            break
    if ans != -1:
        print(ans)
    else:
        print("-1")

if __name__ == "__main__":
    main()

Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
def main():
    n, m = map(int, input().split())
    ans = -1
    if m != 0:
        lst = [None]*m
        for i in range(m):
            s, c = map(int, input().split())
            lst[i] = [s, c]
    for i in range(1000):
        f = True
        if len(str(i)) != n:
            f = False
            continue
        if m != 0:
            for v in lst:
                if str(i)[v[0]-1] != str(v[1]):
                    f = False
        if f:
            ans = i
            break
    if ans != -1:
        print(ans)
    else:
        print("-1")

if __name__ == "__main__":
    main()

Problem: p02761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M = [int(i) for i in input().split()]
S = []
C = []

for i in range(M):
   s,c = [int(i) for i in input().split()]
   S.append(s)
   C.append(c)

ans = [0] * N
for i in range(M):
    if ans[S[i] - 1] != 0 and ans[S[i] - 1] != C[i]:
        print(-1)
        exit()
    elif S[i] - 1 == 0 and C[i] == 0:
        print(-1)
        exit()
    ans[S[i]-1] = C[i]


if ans[0] == 0:
    ans[0] == 1
else:
    print(''.join(map(str,ans)))

Failing test case input:
3 1
0 1
1 1

Expected output:
101


Actual output:

Fixed submission (verdict: Accepted):
N,M = [int(i) for i in input().split()]
S = []
C = []

for i in range(M):
   s,c = [int(i) for i in input().split()]
   S.append(s)
   C.append(c)

ans = [-1] * N
for i in range(M):
    if ans[S[i] - 1] != -1 and ans[S[i] - 1] != C[i]:
        print(-1)
        exit()
    elif S[i] - 1 == 0 and C[i] == 0 and N != 1:
        print(-1)
        exit()
    ans[S[i]-1] = C[i]

for i in range(1,N):
    if ans[i] == -1:
        ans[i] = 0

if ans[0] == -1 and N != 1:
    ans[0] = 1
elif N == 1 and ans[0] == -1:
    ans[0] = 0

print(''.join(map(str,ans)))
Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = []
N,M = [int(i) for i in input().split(" ")]

for  _ in range(M):
    S.append([int(i) for i in input().split(" ")])


flag = False
ans = []

for i in range(1,1000):
    try:
        if [int(str(i)[s[0]-1]) == s[1] for s in S].count(True) == M and len(str(i)) == N:
            ans.append(i)
            flag = True
    except:
        pass

if flag:
    print(min(ans))
else:
    print("-1")

Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
S = []
N,M = [int(i) for i in input().split(" ")]

for  _ in range(M):
    s,c = input().split(" ")
    S.append([int(s)-1,c])

start = 0 if N == 1  else 10**(N-1)
ans = -1
for num in range(start,10**N):
    flag = True
    s_num = str(num)
    for s in S:
        if (s_num[s[0]] != s[1]):
            flag = False
            break
    if (flag):
        ans = num
        break

print (ans)

Problem: p02761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]

for i in range(1,10**n):
    s = str(i).zfill(3)
    c = 0
    for i in range(m):
        if sc[i] == [1,0]:
            print(-1)
            sys.exit()
            
        if s[sc[i][0]-1] == str(sc[i][1]):
            c += 1
    
    if c == m:
        print(s)
        sys.exit()

print(-1)
    

Failing test case input:
3 0
1 1
0 1

Expected output:
100


Actual output:
001


Fixed submission (verdict: Accepted):
import sys
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]

for i in range(10**n):
    s = str(i)
    if len(s) != n:
        continue
    c = 0
    for i in range(m):
        if n >= 2:
            if sc[i] == [1,0]:
                print(-1)
                sys.exit()
            
        if s[sc[i][0]-1] == str(sc[i][1]):
            c += 1
    
    if c == m:
        print(s)
        sys.exit()

print(-1)

Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
n,m=map(int,input().split())
l=[-1]*(n)
for i in range(m):
    s,c=map(int,input().split())
    if l[s-1]==-1 or l[s-1]==c:
        l[s-1]=c
    else:
        print(-1)
        sys.exit()
if l[0]==0 and len(l)!=1:
    print(-1)
    sys.exit()
for i in range(n):
    if l[i]==-1:
        l[i]=0
if l[0]==0 and len(l)==1:
    l[0]=1

if l[0]==0 and len(l)==1:
    print(0)
else:
    for i in range(n):
        print(l[i],end="")

Failing test case input:
3 0
2 1
2 2

Expected output:
100


Actual output:
000

Fixed submission (verdict: Accepted):
import sys
n,m=map(int,input().split())
l=[-1]*(n)
for i in range(m):
    s,c=map(int,input().split())
    if l[s-1]==-1 or l[s-1]==c:
        l[s-1]=c
    else:
        print(-1)
        sys.exit()
if l[0]==0 and len(l)!=1:
    print(-1)
    sys.exit()
for i in range(n):
    if l[i]==-1:
        l[i]=0
if l[0]==0 and len(l)!=1:
    l[0]=1

if l[0]==0 and len(l)==1:
    print(0)
else:
    for i in range(n):
        print(l[i],end="")
Problem: p02761
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M = map(int,input().split())

X = [0] * N
R = [0] *  N

ans = True
for i in range(M):
    s,c = map(int,input().split())
    
        
    if R[s-1] == 0:
        X[s-1] = c
        R[s-1] = "T"
        
    elif R[s-1] == "T" and X[s-1] != c or (s == 1 and c == 0):
        ans = False
        break
        
if ans:
    if X[0] == 0:
            cnt = 1
    else:
        cnt = X[0]
    for i in range(1,N):
        cnt = cnt * 10 + X[i]
        
    print(cnt)

else:
    print(-1)

Failing test case input:
3 2
1 0
0 0

Expected output:
-1


Actual output:
100


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())

X = [0] * N
R = [0] *  N

ans = True
for i in range(M):
    s,c = map(int,input().split())
    
        
    if R[s-1] == 0:
        X[s-1] = c
        R[s-1] = "T"
        
    elif R[s-1] == "T" and X[s-1] != c :
        ans = False
        break
        
if ans:
    if X[0] == 0 and R[0] == 0 and N != 1:
        cnt = "1"
    else:
        cnt = str(X[0])
    for i in range(1,N):
        cnt = cnt + str(X[i])
    
    if len(cnt) == len(str(int(cnt))):
        
        print(cnt)
    else:
        print(-1)
else:
    print(-1)

Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())

dic = [set() for _ in range(n)]



for i in range(m) :
    s, c = map(int, input().split())
    dic[s-1].add(c)


for i in range(len(dic)) :
    if len(dic[i]) > 1 :
        print(-1)
        exit()
    if n != 1 and len(dic[i]) == 1 and i == 0:
        if list(dic[i])[0] == 0 :
            print(-1)
            exit()
    if len(dic[i]) == 0 :
        if i == 0 :
            dic[i].add(1)
        else :
            dic[i].add(0)

ans = 0
mul = 10 ** (n-1)

for i in range(len(dic)) :
    ans += (list(dic[i])[0] * mul)
    mul /= 10

print(int(ans))


Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())

dic = [set() for _ in range(n)]



for i in range(m) :
    s, c = map(int, input().split())
    dic[s-1].add(c)


for i in range(len(dic)) :
    if len(dic[i]) > 1 :
        print(-1)
        exit()
    if n != 1 and len(dic[i]) == 1 and i == 0:
        if list(dic[i])[0] == 0 :
            print(-1)
            exit()
    if len(dic[i]) == 0 :
        if i == 0 and m != 0:
            dic[i].add(1)
        elif m == 0 and n > 1 and i == 0:
            dic[i].add(1)
        else :
            dic[i].add(0)

ans = 0
mul = 10 ** (n-1)

for i in range(n) :
    ans += (list(dic[i])[0] * mul)
    mul /= 10

print(int(ans))
Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = list(map(int, input().split(' ')))
r = [ None for i in range(N) ]

illegal = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None and r[s-1] != c:
    illegal = True
    break
  r[s-1] = c

v = -1
if not illegal:
  for i in range(N):
    if r[i] is None:
      r[i] = 0
  v = sum(r[i] * 10**i for i in range(N))
  if v < 10**(N-1) and not (N == 1 and v == 0):
    v = -1

print(v)

Failing test case input:
3 0
1 0

Expected output:
100


Actual output:
-1


Fixed submission (verdict: Accepted):
N, M = list(map(int, input().split(' ')))
r = [ None for i in range(N) ]

illegal = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None and r[s-1] != c:
    illegal = True
    break
  r[s-1] = c

v = -1
if not illegal:
  for i in range(N):
    if r[i] is None:
      if i == 0 and N != 1:
        r[i] = 1
      else:
        r[i] = 0
  v = sum(r[i] * 10**(N-1-i) for i in range(N))
  if v < 10**(N-1) and not (N == 1 and v == 0):
    v = -1

print(v)

Problem: p02761
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n, m = map(int, input().split())
    nums = [10]*n
    result = None
    for _ in range(m):
        s, e = map(int, input().split())
        if nums[s-1] == 10:
            nums[s - 1] = e
        else:
            if nums[s - 1] != e:
                result = '-1'
                break

    for i in range(n):
        if i == 0 and nums[i] == 10:
            nums[i] = 1
        elif nums[i] == 10:
            nums[i] = 0

    if result == '-1':
        print('-1')
    elif nums[0] == 0:
        print('-1')
    else:
        print(''.join(map(str, nums)))


if __name__ == "__main__":
    main()


Failing test case input:
1 0
0 0
2 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
def main():
    n, m = map(int, input().split())
    nums = [10]*n
    result = None
    for _ in range(m):
        s, e = map(int, input().split())
        if nums[s-1] == 10:
            nums[s - 1] = e
        else:
            if nums[s - 1] != e:
                result = '-1'
                break

    for i in range(n):
        if i == 0 and nums[i] == 10 and len(nums) > 1:
            nums[i] = 1
        elif nums[i] == 10:
            nums[i] = 0

    if result == '-1':
        print('-1')
    elif nums[0] == 0 and len(nums) > 1:
        print('-1')
    else:
        print(''.join(map(str, nums)))


if __name__ == "__main__":
    main()