problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p02761
u218838821
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N , M = map(int,input().split())\nsc = []\nfor i in range(M):\n new = list(map(int,input().split()))\n if i != 0:\n for j in range(len(sc)):\n if new[0] == sc[j][0]:\n if new[1] != sc[j][1]:\n print(-1)\n exit()\n else:\n break\n else:\n if j == len(sc)-1:\n sc.append(new)\n else:\n sc.append(new)\n \nans = 0\nfor i in range(len(sc)):\n ans += sc[i][1] * (10**(sc[i][0]-1))\nif len(str(ans)) == N:\n print(ans)\nelse:\n print(-1)', 'N , M = map(int,input().split())\nsc = []\nfor i in range(M):\n new = list(map(int,input().split()))\n if i != 0:\n for j in range(len(sc)):\n if new[0] == sc[j][0]:\n if new[1] != sc[j][1]:\n print(-1)\n exit()\n else:\n break\n else:\n sc.append(new)\n else:\n sc.append(new)\n \nans = 0\nfor i in range(len(sc)):\n ans += sc[i][1] * (10**(sc[i][0]-1))\nif len(str(ans)) == N:\n print(ans)\nelse:\n print(-1)', 'N , M = map(int,input().split())\nSC = []\nfor i in range(M):\n SC.append(list(map(int,input().split())))\n\nif M == 0:\n if N == 1:\n print(0)\n else:\n print(10**(N-1))\n exit()\n \nif N == 1:\n for i in range(10):\n n = str(i)\n for j in range(M):\n if int(n[SC[j][0]-1]) != SC[j][1]:\n break\n if j == M-1:\n print(i)\n exit()\n \nelse:\n for i in range(10**(N-1),10**N):\n n = str(i)\n for j in range(M):\n if int(n[SC[j][0]-1]) != SC[j][1]:\n break\n if j == M-1:\n print(i)\n exit()\n \nprint(-1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s694918182', 's736534427', 's107946598']
[9240.0, 9200.0, 9248.0]
[27.0, 31.0, 29.0]
[489, 460, 684]
p02761
u221537793
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N, M = map(int, input().split())\nsc = [tuple(map(int, input().split())) for _ in range(M)]\ndef cands(N):\n if N ==1:\n return range(10)\n else:\n return range(10 ** (N-1), 10 **N)\n\ndef main(N, sc):\n nums = cands(N)\n print(nums)\n for n in nums:\n try:\n for s,c in sc:\n assert(int(str(n)[s-1]) == c)\n except AssertionError as e:\n continue\n return n\n else:\n return -1\nprint(main(N, sc))', 'N, M = map(int, input().split())\nsc = [tuple(map(int, input().split())) for _ in range(M)]\ndef cands(N):\n if N ==1:\n return range(10)\n else:\n return range(10 ** (N-1), 10 **N)\n\ndef main(N, sc):\n nums = cands(N)\n for n in nums:\n try:\n for s,c in sc:\n assert(int(str(n)[s-1]) == c)\n except AssertionError as e:\n continue\n return n\n else:\n return -1\nprint(main(N, sc))']
['Wrong Answer', 'Accepted']
['s989788800', 's364871221']
[3064.0, 3064.0]
[18.0, 19.0]
[475, 459]
p02761
u221580805
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n, m = map(int, input().split())\n\ns_list = []\nc_list = []\nfor _ in range(m):\n s, c = map(int, input().split())\n s_list.append(s)\n c_list.append(c)\nans = ["1"]\nans.extend(["0"]*(n-1))\n\nif m == 1:\n if s_list[0] == 1:\n ans = [str(c_list[0])]\n else:\n ans[s_list[0]-1] = str(c_list[0])\nelif c_list[0] == "0":\n ans = ["-1"]\nelse:\n for s, c in zip(s_list, c_list):\n if len(ans) < s:\n ans = ["-1"]\n break\n elif ans[s-1] != "0" and ans[s-1] != str(c):\n ans = ["-1"]\n break\n ans[s-1] = str(c)\nprint("".join(ans))', 'n, m = map(int, input().split())\nnums = [list(map(int, input().split())) for _ in range(m)]\n\nfor i in range(1000):\n is_ok = True\n num_str = str(i)\n if len(num_str) != n:\n continue\n for s, c in nums:\n if num_str[s-1] != str(c):\n is_ok = False\n break\n if is_ok:\n print(num_str)\n exit(0)\nprint(-1)']
['Runtime Error', 'Accepted']
['s967351203', 's052437316']
[3064.0, 3060.0]
[18.0, 18.0]
[544, 321]
p02761
u222668979
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["import sys\nn, m = map(int, input().split())\nsc = [list(map(int, input().split())) for _ in range(m)]\n\nans = [-1] * n\nfor i in sc:\n s,c=sc[i]\n if (ans[s-1] == c) | (ans[s-1] == -1):\n ans[s-1] = c\n else:\n print(-1)\n sys.exit()\n\nfor i in range(n):\n if ans[i] == -1:\n if i == 0:\n ans[i] = 1\n else:\n ans[i] = 0\n\nif n != 1:\n if ans[0] == 0:\n print(-1)\n sys.exit()\n\nprint(*ans, sep='')\n", "n, m = map(int, input().split())\nsc = [list(map(int, input().split())) for _ in range(m)]\n\nans = [-1] * n\nfor s, c in sc:\n if (ans[s-1] == c) | (ans[s-1] == -1):\n ans[s-1] = c\n else:\n print(-1)\n exit()\n\nfor i in range(n):\n if ans[i] == -1:\n if (i == 0) & (n != 1):\n ans[i] = 1\n else:\n ans[i] = 0\n\nif n != 1 and ans[0] == 0:\n print(-1)\n exit()\n\nprint(*ans, sep='')\n"]
['Runtime Error', 'Accepted']
['s714949979', 's051233060']
[3064.0, 9180.0]
[17.0, 29.0]
[465, 436]
p02761
u225020286
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N,M=map(int,input().split())\nsc=[list(map(int,input().split())) for i in range(M)]\nguess=["0"]*N\nfor i in sc:\n guess[i[0]-1]=i[1]\nif guess[0]==0:\n print("-1")\nelse:\n for i in guess:\n print(i,end="")\n', 'N,M=map(int,input().split())\nS=[]\nC=[]\nfor i in range(M):\n s1,c1=[int(i) for i in input().split()]\n S.append(s1)\n C.append(c1)\nfor i in range(pow(10,N),pow(10,N+1)):\n i=str(i)\n for s,c in zip(S,C):\n if i[s]==c:\n print(i)\n exit()\nelse:\n print("-1")', 'N,M=map(int,input().split())\nSC=[list(map(int,input().split())) for i in range(M)]\nbegin=10**(N-1)\nend=10**N\nif N==1:\n begin=0\nfor i in range(begin,end):\n i=str(i)\n for s,c in SC:\n if i[s-1]!=c:\n break\n else:\n print(i)\n exit()\nprint(-1)', 'N,M=map(int,input().split())\nsc=[list(map(int,input().split())) for i in range(M)]\nguess=["0"]*N\nfor i in sc:\n guess[i[0]-1]=i[1]\nguess=list(map(str,guess))\nif guess[0]=="0":\n print("-1")\nelse:\n for i in guess:\n print(i,end="")\n', 'N,M=map(int,input().split())\nSC=[list(map(int,input().split())) for i in range(M)]\nbegin=10**(N-1)\nend=10**N\nfor i in range(begin,end):\n i=str(i)\n for s,c in SC:\n if i[s-1]!=c:\n break\n else:\n print(i)\n exit()\nprint(-1)', 'N,M=map(int,input().split())\nS=[]\nC=[]\nans=-1\nfor i in range(M):\n s1,c1=[int(i) for i in input().split()]\n S.append(s1)\n C.append(c1)\nfor i in range(pow(10,N),pow(10,N+1)):\n i=str(i)\n for s,c in zip(S,C):\n if i[s-1]!=c:\n break\n else:\n ans=i\n if ans!=-1:\n break\nprint(ans)', 'N,M=map(int,input().split())\nSC=[list(map(int,input().split())) for i in range(M)]\nbegin=10**N-1\nend=10**N\nfor i in range(begin,end):\n i=str(i)\n for s,c in SC:\n if i[s-1]!=c:\n break\n else:\n print(i)\n exit()\nprint(-1)', 'N,M=map(int,input().split())\nSC=[list(map(int,input().split())) for i in range(M)]\nbegin=10**N-1\nend=10**N\nif N==1:\n print(SC[0][1])\nfor i in range(begin,end):\n i=str(i)\n for s,c in SC:\n if i[s-1]!=c:\n break\n else:\n print(i)\n exit()\nprint(-1)', 'N,M=map(int,input().split())\nSC=[list(map(int,input().split())) for i in range(M)]\nl=10**(N-1)\nif N==1:\n l=0\nfor i in range(l,10**N):\n i=str(i)\n for s,c in SC:\n if i[s-1]!=c:\n break\n else:\n print(i)\n exit()\nprint("-1")\n', 'N,M=map(int,input().split())\nsc=[list(map(int,input().split())) for i in range(M)]\nguess=["0"]*N\nfor i in sc:\n guess[i[0]-1]=i[1] \nif guess[0]=="0":\n print("-1")\nelse:\n for i in guess:\n print(i,end="")\n', 'N,M=map(int,input().split())\nSC=[list(map(int,input().split())) for i in range(M)]\nbegin=10**(N-1)\nend=10**N\nif N==1:\n begin=0\nfor i in range(begin,end):\n i=str(i)\n for s,c in SC:\n if i[s-1]!=str(c):\n break\n else:\n print(i)\n exit()\nprint(-1)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s095847813', 's121014418', 's212682223', 's262929141', 's267819644', 's288813416', 's377399004', 's634916116', 's786555916', 's811366639', 's927283796']
[3060.0, 3064.0, 3064.0, 3060.0, 3064.0, 3064.0, 3064.0, 3064.0, 3060.0, 3060.0, 3064.0]
[18.0, 27.0, 20.0, 17.0, 18.0, 24.0, 17.0, 17.0, 19.0, 17.0, 18.0]
[205, 266, 254, 234, 235, 300, 233, 260, 237, 208, 259]
p02761
u225845681
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N, M, *sc = map(int, open(0).read().split())\ns=[]\nc=[]\nfor i in range(2*M):\n if i%2 == 0:\n s.append(sc[i])\n else:\n c.append(sc[i])\n\nans = 0\n\nfor j in range(M):\n if N == 2 and s[j] == 1 and c[j] == 0:\n ans = -1\n break\n elif N == 3 and s[j] == 1 and c[j] == 0:\n ans = -1\n break\n\nfor k in range(M):\n for l in range(M):\n if not k == l and s[k] == s[l] and c[k] != c[l]:\n ans = -1\n break\n\n\nkotae = [0,0,0]\nif ans == 0:\n for m in range(M):\n kotae[2-s[m]] = c[m]\n print(kotae)\n for n in range(N):\n if N-1 == n and kotae[2-n] == 0 and N != 1:\n kotae[2-n] = 1\n ans = kotae[0]*100 + kotae[1]*10 + kotae[2]\nprint(ans)', 'N, M, *sc = map(int, open(0).read().split())\ns=[]\nc=[]\nfor i in range(2*M):\n if i%2 == 0:\n s.append(sc[i])\n else:\n c.append(sc[i])\n\nans = 0\n\nfor j in range(M):\n if N == 2 and s[j] == 1 and c[j] == 0:\n ans = -1\n break\n elif N == 3 and s[j] == 1 and c[j] == 0:\n ans = -1\n break\n\nfor k in range(M):\n for l in range(M):\n if not k == l and s[k] == s[l] and c[k] != c[l]:\n ans = -1\n break\n\n\nkotae = [0,0,0]\nif ans == 0:\n for m in range(M):\n kotae[s[m]+1-N] = c[m]\n for n in range(N):\n if N-1 == n and kotae[2-n] == 0 and N != 1:\n kotae[2-n] = 1\n ans = kotae[0]*100 + kotae[1]*10 + kotae[2]\nprint(ans)', 'N, M, *sc = map(int, open(0).read().split())\ns=[]\nc=[]\nfor i in range(2*M):\n if i%2 == 0:\n s.append(sc[i])\n else:\n c.append(sc[i])\n\nans = 0\n\nfor j in range(M):\n if N == 2 and s[j] == 1 and c[j] == 0:\n ans = -1\n break\n elif N == 3 and s[j] == 1 and c[j] == 0:\n ans = -1\n break\n\nfor k in range(M):\n for l in range(M):\n if not k == l and s[k] == s[l] and c[k] != c[l]:\n ans = -1\n break\n\n\nkotae = [0,0,0]\nif ans == 0:\n for m in range(M):\n kotae[s[m]+(3-N)-1] = c[m]\n for n in range(N):\n if N-1 == n and kotae[2-n] == 0 and N != 1:\n kotae[2-n] = 1\n ans = kotae[0]*100 + kotae[1]*10 + kotae[2]\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s540411581', 's823535501', 's877705830']
[3064.0, 3064.0, 3192.0]
[18.0, 17.0, 18.0]
[720, 707, 711]
p02761
u230621983
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["n, m = map(int, input().split())\ntmp = [10]*n\n\nfor _ in range(m):\n s,c = map(int, input().split())\n tmp[s-1] = min(tmp[s-1],c)\nfor i in range(n):\n if tmp[i] == 10:\n tmp[i] = 0\n\nans = ''.join(map(str,tmp))\nif ans[0] == '0':\n print('-1')\nelse:\n print(num)", "n, m = map(int, input().split())\ntmp = [10]*n\n\nfor _ in range(m):\n s,c = map(int, input().split())\n if tmp[s-1] == 10:\n tmp[s-1] = c\n else:\n print('-1')\n exit()\n\nfor i in range(n):\n if tmp[i] == 10:\n if i == 0 and n != 1:\n tmp[i] = 1\n else:\n tmp[i] = 0\n\nans = ''.join(map(str,tmp))\n\nif n != 1 and ans[0] == '0':\n print('-1')\nelse:\n print(ans)", "n, m = map(int, input().split())\ntmp = [10]*n\n\nfor _ in range(m):\n s,c = map(int, input().split())\n if tmp[s-1] == 10 or tmp[s-1]==c:\n tmp[s-1] = c\n else:\n print('-1')\n exit()\n\nfor i in range(n):\n if tmp[i] == 10:\n if i == 0 and n != 1:\n tmp[i] = 1\n else:\n tmp[i] = 0\n\nans = ''.join(map(str,tmp))\n\nif n != 1 and ans[0] == '0':\n print('-1')\nelse:\n print(ans)"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s180633375', 's809002362', 's763863544']
[3064.0, 3064.0, 3192.0]
[18.0, 17.0, 18.0]
[275, 417, 432]
p02761
u232873434
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["\nN,M = map(int, input().split())\nanswer = ['0']* N\ns_list = []\nc_list = []\nend = 0\nfor i in range(0,M):\n s, c = map(int, input().split())\n answer[s-1]= str(c)\n s_list.append(s)\n c_list.append(c)\n for i in range(0,len(s_list)):\n if (s_list[i] == s) & (c_list[i] != c):\n end =1\n break\n\nif end == 1:\n print(-1)\nelif (len(answer) == 1) & (answer[0]=='0'):\n print(0)\nelif not('1' in s_list) :\n answer[0] ='1'\n print(int(''.join(answer)))\nelif answer[0] == '0':\n print(-1)\nelse:\n print(int(''.join(answer)))", "\nN,M = map(int, input().split())\nif N != 1:\n answer = ['0']* (N-1)\n answer.insert(0,'1')\nelse:\n answer =['0']\ns_list = []\nc_list = []\nend = 0\nfor i in range(0,M):\n s, c = map(int, input().split())\n answer[s-1]= str(c)\n s_list.append(s)\n c_list.append(c)\n for i in range(0,len(s_list)):\n if (s_list[i] == s) & (c_list[i] != c):\n end =1\n break\n\nif end == 1:\n print(-1)\nelif (len(answer) == 1) & (answer[0]=='0'):\n print(0)\nelif answer[0] == '0':\n print(-1)\nelse:\n print(int(''.join(answer)))\n\n\n"]
['Wrong Answer', 'Accepted']
['s626165726', 's322145465']
[3064.0, 3064.0]
[17.0, 17.0]
[564, 558]
p02761
u235027735
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n, m = map(int, input().split())\n\n\na = [[],[],[]]\nfor i in range(m):\n s, c = map(int, input().split())\n if not c in a[s-1]:\n a[s-1].append(c)\n \nans = 0\nif m==0:\n if n==3:\n print(100)\n elif n==2:\n print(10)\n else :\n print(0)\nelif (len(a[0]) > 1) or (len(a[1]) > 1) or (len(a[2]) > 1):\n print(-1)\nelif (n==3 or n==2) and len(a[0]) == 0:\n a[0][0]=1\n if (n==3 or n==2) and a[0][0] == 0:\n print(-1)\n else:\n for i in range(n):\n if len(a[i]) == 1:\n ans += a[i][0] * (10**(n-1-i))\n print(ans)\n\n\n\n\n\n\n', 'n, m = map(int, input().split())\n\n\na = [[],[],[]]\nfor i in range(m):\n s, c = map(int, input().split())\n if not c in a[s-1]:\n a[s-1].append(c)\n \nans = 0\nif m==0:\n if n==3:\n print(100)\n elif n==2:\n print(10)\n else :\n print(0)\nelif (len(a[0]) > 1) or (len(a[1]) > 1) or (len(a[2]) > 1):\n print(-1)\nelse:\n if (n==3 or n==2) and len(a[0]) == 0:\n a[0].append(1)\n if (n==3 or n==2) and a[0][0] == 0:\n print(-1)\n else:\n for i in range(n):\n if len(a[i]) == 1:\n ans += a[i][0] * (10**(n-1-i))\n print(ans)\n\n\n\n\n\n\n']
['Runtime Error', 'Accepted']
['s016885867', 's731591138']
[3064.0, 3064.0]
[18.0, 17.0]
[592, 613]
p02761
u237299453
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n, m = map(int, input().split())\ns = [0]*m\nc = [0]*m\nfor i in range(m):\n s[i], c[i] = map(int, input().split())\nif max(s) > n:\n print("-1")\n exit()\nk1 = [100, 10, 1]\nan =[]\nzeros =[]\nfor i in range(m):\n if c[i] == 0:\n zeros.append(s[i])\n an.append(c[i] * k1[s[i] - 1])\n\nfor i in range(m):\n for j in range(m):\n if s[i] == s[j]:\n if c[i] != c[j]:\n print("-1")\n exit()\nif len(sum(an)) != n:\n print("-1")\n exit()\nif 10 ** max(zeros) > sum(an):\n print("-1")\n exit()\nfor i in range(m):\n if an.count(an[i]) != 1:\n an[i] = 0\nif sum(an) == 0:\n print("-1")\n exit()\nprint(sum(an))', 'n, m = map(int, input().split())\ns = [0]*m\nc = [0]*m\nfor i in range(m):\n s[i], c[i] = map(int, input().split())\nif max(s) > n:\n print("-1")\n exit()\nk1 = [100, 10, 1]\nan =[]\nzeros =[]\nfor i in range(m):\n if c[i] == 0:\n zeros.append(s[i])\n an.append(c[i] * k1[s[i] - 1])\n\nfor i in range(m):\n for j in range(m):\n if s[i] == s[j]:\n if c[i] != c[j]:\n print("-1")\n exit()\n \nif 10 ** max(zeros) > sum(an):\n print("-1")\n exit()\nfor i in range(m):\n if an.count(an[i]) != 1:\n an[i] = 0\nif sum(an) == 0:\n print("-1")\n exit()\nprint(sum(an))', "N, M = map(int,input().split())\nsc = []\nfor _ in range(M):\n s, c = input().split()\n s = int(s)\n if s > N:\n print('-1')\n exit()\n sc.append([s, c])\n \nans = -1\nif N == 1:\n start = 0\nelse:\n start = 10 ** (N - 1)\nfor i in range(start, 10 ** N):\n str_num = str(i)\n for s, c in sc:\n if str_num[s - 1] != c:\n break\n else:\n ans = i\n break\nprint(ans)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s819294277', 's987986006', 's907186410']
[9276.0, 9140.0, 9168.0]
[27.0, 26.0, 29.0]
[610, 574, 413]
p02761
u238084414
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N, M = map(int, input().split())\nsc = [list(map(int, input().split())) for _ in range(M)]\nans = 0\nexist = False\nif N == 1:\n x = 0\nelse:\n x = 10 ** (N - 1)\nfor i in range(x, 1000):\n s = str(i)\n f = True\n for j in range(M):\n print(i, sc[j][0], sc[j][1], s[sc[j][0] - 1])\n if int(s[sc[j][0] - 1]) != sc[j][1]:\n f = False\n break\n if f:\n ans = i\n exist = True\n break\nprint(ans if exist else -1)', 'N, M = map(int, input().split())\nsc = [list(map(int, input().split())) for _ in range(M)]\nans = 0\nexist = False\nif N == 1:\n x = 0\nelse:\n x = 10 ** (N - 1)\nfor i in range(x, 1000):\n s = str(i)\n f = True\n for j in range(M):\n if int(s[sc[j][0] - 1]) != sc[j][1]:\n f = False\n break\n if f:\n ans = i\n exist = True\n break\nprint(ans if exist else -1)']
['Wrong Answer', 'Accepted']
['s935529257', 's567335804']
[3572.0, 3064.0]
[21.0, 18.0]
[420, 370]
p02761
u238504302
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['def main():\n N, M = map(int,input().split())\n sc = list(list(input().split()) for _ in range(M))\n\n li = [""] * N\n\n for i in range(M):\n j = li[int(sc[i][0]) - 1]\n if j == "": li[int(sc[i][0]) - 1] = sc[i][1]\n elif j != sc[i][1]: return -1\n\n for i in range(N):\n if i == 0:\n if li[0] == "0" and N != 1: return -1\n if li[0] == "":\n if N == 1: li[0] = "0"\n elif: li[0] = "1"\n elif li[i] == "": li[i] = "0"\n\n return "".join(li)\n\nprint(main())', 'def main():\n N, M = map(int,input().split())\n sc = list(list(input().split()) for _ in range(M))\n\n li = [""] * N\n\n for i in range(M):\n j = li[int(sc[i][0]) - 1]\n if j == "": li[int(sc[i][0]) - 1] = sc[i][1]\n elif j != sc[i][1]: return -1\n\n for i in range(N):\n if i == 0:\n if li[0] == "0" and N != 1: return -1\n if li[0] == "":\n if N == 1: li[0] = "0"\n else: li[0] = "1"\n elif li[i] == "": li[i] = "0"\n\n return "".join(li)\n\nprint(main())']
['Runtime Error', 'Accepted']
['s833291822', 's826100545']
[8912.0, 9084.0]
[26.0, 31.0]
[481, 481]
p02761
u238940874
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n,m=map(int,input().split())\nsc=[list(map(int,input().split())) for i in range(m)]\nstart=10**(n-1)\nend=10**n\nif n == 1:\n start = 0\nfor i in range(start,end):\n i=str(i)\n for s,c in sc:\n if i[s-1] != str(c):\n break\n else:\n print(i)\n break\nprint(-1)', 'n,m=map(int,input().split())\nsc=[list(map(int,input().split())) for i in range(m)]\n\nfor i in range(10**(n-1),10**n):\n i=str(i)\n for s,c in sc:\n if i[s-1] != str(c):\n break\n else:\n print(i)\n break\nprint(-1)', 'n,m=map(int,input().split())\nsc=[list(map(int,input().split())) for _ in range(m)]\nstart=10**(n-1)\nif n==1:\n start=0\nfor i in range(start,1001):\n i = str(i)\n for s,c in sc:\n if i[s-1] != str(c):\n break\n else:\n print(i)\n exit()\nprint(-1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s772303867', 's848960606', 's181931696']
[3064.0, 3064.0, 3064.0]
[18.0, 18.0, 18.0]
[290, 246, 280]
p02761
u239528020
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['# C\nN, M = list(map(int, input().split()))\n\nflag = 0\nans = [0]*M\nans_flag = [0]*M\n\nsc = [list(map(int, input().split())) for _ in range(M)]\nfor i in range(M):\n s, c = sc[i]\n if ans_flag[s-1] == 1:\n if ans[s-1] != c:\n flag = 1\n break\n ans_flag[s-1] = 1\n ans[s-1] = c\n\nif flag == 1:\n print("-1")\nelse:\n if ans[0] == 0 and ans_flag[0]==1:\n print("-1")\n else:\n if ans[0]==0:\n ans[0] = 1\n print(ans) \n\n \n', '# C\nN, M = list(map(int, input().split()))\n\nflag = 0\nans = [0]*M\nans_flag = [0]*M\n\nsc = [list(map(int, input().split())) for _ in range(M)]\nfor i in range(M):\n s, c = sc[i]\n if ans_flag[s-1] == 1:\n if ans[s-1] != c:\n flag = 1\n break\n ans_flag[s-1] = 1\n ans[s-1] = c\n\nif flag == 1:\n print("-1")\nelse:\n if ans[0] == 0 and ans_flag[0]==1:\n print("-1")\n else:\n if ans[0]==0:\n ans[0] = 1\n for i in ans:\n print(i, end="")\n\n\n \n', '#!/usr/bin/env python3\n\nn, m = map(int, input().split())\n\nflag = 0\nans = [None for i in range(n)]\n# print(ans)\nfor i in range(m):\n s, c = map(int, input().split())\n if ans[s-1] is None or ans[s-1] == c:\n ans[s-1] = c\n else:\n flag = 1\n break\n\n# print(flag)\nif n == 1:\n if ans[0] is None:\n ans[0] = 0\n print("".join(map(str, ans)) if flag == 0 else -1)\nelse:\n if ans[0] == 0:\n flag = 1\n if ans[0] is None:\n ans[0] = 1\n for i in range(1, len(ans)):\n if ans[i] is None:\n ans[i] = 0\n\n print("".join(map(str, ans)) if flag == 0 else -1)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s173880974', 's867641332', 's758251216']
[3064.0, 3064.0, 3064.0]
[17.0, 17.0, 18.0]
[485, 516, 618]
p02761
u239653493
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['a,b,c = map(int, input().split())\nd,e,f = map(int, input().split())\ng,h,i = map(int, input().split())\nn=int(input())\nA = []\nfor i in range(n):\n A.append(int(input()))\nif (a in A) and (b in A) and (c in A):\n print("Yes")\nelif d in A and e in A and f in A:\n print("Yes")\nelif g in A and h in A and i in A:\n print("Yes")\nelif a in A and d in A and g in A:\n print("Yes")\nelif b in A and e in A and h in A:\n print("Yes")\nelif c in A and f in A and i in A:\n print("Yes")\nelif a in A and e in A and i in A:\n print("Yes")\nelif c in A and e in A and g in A:\n print("Yes")\nelse:\n print("No")', 'n,m=map(int,input().split())\ns = [0] * m\nc = [0] * m\nfor i in range(m):\n s[i], c[i] = map(int, input().split())\nk=["0"]*n\nif m==0 and n==1:\n print(0)\nelif m==0 and n!=1:\n print(10**(n-1))\nelse:\n for i in range(m):\n if k[s[i]-1]=="0":\n k[s[i]-1]=c[i]\n elif k[s[i]-1]==c[i]:\n k[s[i]-1]=c[i]\n else:\n print(-1)\n break\n\n else:\n t=0\n if k[0]=="0":\n k[0]=1\n if k[0]==0 and n==1:\n print(0)\n elif k[0]==0 and n!=1:\n print(-1)\n else:\n for i in range(n):\n t=t+10**(n-1-i)*int(k[i])\n print(t)']
['Runtime Error', 'Accepted']
['s517828088', 's342787770']
[3064.0, 3064.0]
[17.0, 19.0]
[614, 665]
p02761
u239917977
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['def main():\n N,M =map(int, input().split())\n s,c=[],[]\n for i in range(M):\n si,ci = map(int, input().split())\n s.append(si)\n c.append(ci)\n \n res=[0]*N\n for si,ci in zip(s,c):\n if res[si-1]== 0:\n res[si-1]=str(ci)\t\n elif res[si-1]!= str(ci):\n print(-1)\n exit()\n \n if res==[\'0\']*N:\n print(-1)\n exit()\n su = int("".join(res))\n if su < 10**(N-1):\n print(-1)\n exit()\n \n print(int("".join(res)))\n \n \nif __name__=="__main__":\n main()', '# import numpy as np\ndef main():\n N,M =map(int, input().split())\n s,c=[],[]\n for i in range(M):\n si,ci = map(int, input().split())\n s.append(si)\n c.append(ci)\n \n res=[0]*N\n for si,ci in zip(s,c):\n if res[si-1]== 0:\n res[si-1]=str(ci)\t\n elif res[si-1]!= str(ci):\n print(-1)\n exit()\n# print(res)\n \n\n# if res[i] ==\'\':\n# res[i]=str(0)\n \n if res==[\'0\']*N:\n print(-1)\n exit()\n su = int("".join(res))\n if su < 10**(N-1):\n print(-1)\n exit()\n \n print(int("".join(res)))\n \n \nif __name__=="__main__":\n main()', '# import numpy as np\ndef main():\n N,M =map(int, input().split())\n s,c=[],[]\n for i in range(M):\n si,ci = map(int, input().split())\n s.append(si)\n c.append(ci)\n \n res=[\'\']*N\n for si,ci in zip(s,c):\n if res[si-1]== "":\n res[si-1]=str(ci)\t\n elif res[si-1]!= str(ci):\n print(-1)\n exit()\n print(res)\n \n for i in range(N):\n if res[i] ==\'\':\n res[i]=str(0)\n \n if res==[\'0\']*N:\n print(-1)\n exit()\n su = int("".join(res))\n if su < 10**(N-1):\n print(-1)\n exit()\n \n print(int("".join(res)))\n \n \nif __name__=="__main__":\n main()', '# import numpy as np\ndef main():\n N,M =map(int, input().split())\n s,c=[],[]\n for i in range(M):\n si,ci = map(int, input().split())\n s.append(si)\n c.append(ci)\n \n res=[\'\']*N\n for si,ci in zip(s,c):\n if res[si-1]== \'\':\n res[si-1]=str(ci)\t\n elif res[si-1]!= str(ci):\n print(-1)\n exit()\n\n \n if res[0]==\'0\':\n if N==1:\n print(0)\n exit()\n else:\n print(-1)\n exit()\n elif res[0]==\'\':\n res[0]=str(1)\n \n for i in range(N):\n if res[i]==\'\':\n res[i]=str(0)\n if M==0 and N==1:\n print(0)\n exit()\n print(int("".join(res)))\n \n \nif __name__=="__main__":\n main()']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s093885543', 's224007200', 's292768372', 's910579600']
[3064.0, 3064.0, 3064.0, 3064.0]
[18.0, 18.0, 17.0, 18.0]
[487, 593, 591, 634]
p02761
u241159583
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N, M = map(int, input().split())\nsc = [list(map(int, input().split())) for _ in range(M)]\n\nans = ["0"] * N\nif N > 1: ans[0] = "1"\nrep = {}\nok = True\n\nfor s,c in sc:\n ans[s-1] = str(c)\n if s in rep and rep[s] != str(c):\n ok = False\n break\n else:\n rep[s] = c\n\nif ok and ans[0] == "0" and N > 1:\n ok = False\n\nelse:\n print("".join(ans) if ok else -1)', 'N, M = map(int, input().split())\nsc = [list(map(int, input().split())) for _ in range(M)]\n\nans = ["0"] * N\nif N > 1: ans[0] = "1"\nrep = {}\nok = True\n\nfor s,c in sc:\n ans[s-1] = str(c)\n if s in rep and rep[s] != str(c):\n ok = False\n break\n else:\n rep[s] = c\n\nif ok and ans[0] == "0" and N > 1:\n ok = False\n\nprint("".join(ans) if ok else -1)', 'n,m = map(int, input().split())\nsc = [list(map(int, input().split())) for _ in range(m)]\n\nans = ["0"] * n\nif n>=2: ans[0] = "1"\n\nok = True\nfor s,c in sc:\n if s-1==0 and n>=2:\n if ans[s-1] == "1" or ans[s-1] == str(c): ans[s-1] = str(c)\n else: ok = False\n else:\n if ans[s-1] == "0" or ans[s-1] == str(c): ans[s-1] = str(c)\n else: ok = False\n\nif n>=2:\n if ans[0] == "0": ok = False\nprint(-1 if not ok else "".join(ans))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s047375114', 's506530287', 's820114563']
[3064.0, 3064.0, 9140.0]
[17.0, 18.0, 31.0]
[360, 352, 454]
p02761
u242031676
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['#!/usr/bin/env python3\n', '#!/usr/bin/env python3\n', 'n, m = map(int, input().split())\nsc = [list(map(int, input().split())) for i in range(m)]\n\nfor i in range(1000):\n x = str(i)\n if len(x)!=n: continue\n can = 1\n for s,c in sc:\n if int(x[s-1])!=c: can = 0\n if can:\n print(i)\n break\nelse: print(-1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s009968548', 's187182184', 's198200016']
[2940.0, 2940.0, 3064.0]
[17.0, 17.0, 18.0]
[23, 23, 323]
p02761
u242580186
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["import sys\nimport time\nimport math\nimport itertools as it\ndef inpl():\n return list(map(int, input().split()))\nst = time.perf_counter()\n# ------------------------------\n\nN, M = inpl()\ndp = [-1] * N\nfor _ in range(M):\n s, c = inpl()\n s -= 1\n if dp[s] not in [-1, c]:\n print(-1)\n sys.exit()\n dp[s] = c\nfor i in range(N):\n if N == 1:\n if dp[i] == -1:\n print(0, end='')\n else:\n print(dp[i], end='')\n else:\n if i == 0:\n if dp[i] == -1:\n print(1, end='')\n elif dp[i] == 0\n print(-1)\n sys.exit()\n else:\n print(dp[i], end='')\n else:\n if dp[i] == -1:\n print(0, end='')\n else:\n print(dp[i], end='')\n \nprint()\n# ------------------------------\ned = time.perf_counter()\nprint('time:', ed-st, file=sys.stderr)\n", "import sys\nimport time\nimport math\nimport itertools as it\ndef inpl():\n return list(map(int, input().split()))\nst = time.perf_counter()\n# ------------------------------\n\nN, M = inpl()\ndp = [-1] * N\nfor _ in range(M):\n s, c = inpl()\n s -= 1\n if dp[s] not in [-1, c]:\n print(-1)\n sys.exit()\n dp[s] = c\nfor i in range(N):\n if N == 1:\n if dp[i] == -1:\n print(0, end='')\n else:\n print(dp[i], end='')\n else:\n if i == 0:\n if dp[i] == -1:\n print(1, end='')\n elif dp[i] == 0:\n print(-1)\n sys.exit()\n else:\n print(dp[i], end='')\n else:\n if dp[i] == -1:\n print(0, end='')\n else:\n print(dp[i], end='')\n \nprint()\n# ------------------------------\ned = time.perf_counter()\nprint('time:', ed-st, file=sys.stderr)\n"]
['Runtime Error', 'Accepted']
['s082421352', 's675097874']
[8952.0, 9204.0]
[28.0, 28.0]
[940, 941]
p02761
u247680229
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N,M=list(map(int,input().split()))\ns=[list(map(int,input().split())) for i in range(M)]\n\nNum=0\nA=[]\nB=[]\nC=[]\n \nif N==3:\n for i in s:\n if i[0]==1:\n A.append(i[1])\n \n elif i[0]==2:\n B.append(i[1])\n \n elif i[0]==3:\n C.append(i[1])\n \n if len(A)==0:\n print(-1)\n elif min(A)==0:\n print(-1)\n else:\n Num+=min(A)*100\n if len(B)==0:\n pass\n elif len(B)!=0:\n Num+=min(B)*10\n if len(C)==0:\n pass\n elif len(C)!=0:\n Num+=min(C)\n print(Num)\n \nelif N==2:\n for i in s:\n if i[0]==1:\n B.append(i[1])\n \n elif i[0]==2:\n C.append(i[1])\n \n if len(B)==0:\n print(-1)\n elif min(B)==0:\n print(-1)\n else:\n Num+=min(B)*10\n if len(C)==0:\n pass\n elif len(C)!=0:\n Num+=min(C)\n print(Num)\n\nelif N==1:\n for i in s:\n if i[0]==1:\n C.append(i[1])\n \n if len(C)!=0:\n N+=min(C)\n print(Num)\n else:\n print(Num)\n \nprint(A)', 'N,M=list(map(int,input().split()))\ns=[list(map(int,input().split())) for i in range(M)]\n\nNum=0\nA=[]\nB=[]\nC=[]\n \nif N==3:\n if M==0:\n print(Num=100)\n \n else:\n for i in s:\n if i[0]==1:\n A.append(i[1])\n \n elif i[0]==2:\n B.append(i[1])\n \n elif i[0]==3:\n C.append(i[1])\n \n if len(A)==0:\n print(-1)\n elif min(A)==0:\n print(-1)\n else:\n Num+=min(A)*100\n if len(B)==0:\n pass\n elif len(B)!=0:\n Num+=min(B)*10\n if len(C)==0:\n pass\n elif len(C)!=0:\n Num+=min(C)\n print(Num)\n \nelif N==2:\n if M==0:\n print(Num=10)\n \n else: \n for i in s:\n if i[0]==1:\n B.append(i[1])\n \n elif i[0]==2:\n C.append(i[1])\n \n if len(B)==0:\n print(-1)\n elif min(B)==0:\n print(-1)\n else:\n Num+=min(B)*10\n if len(C)==0:\n pass\n elif len(C)!=0:\n Num+=min(C)\n print(Num)\n\nelif N==1:\n if M==0:\n print(0)\n else;\n for i in s:\n if i[0]==1:\n C.append(i[1])\n \n if len(C)!=0:\n N+=min(C)\n print(Num)\n else:\n print(Num)\n \n', 'import sys\nN,M=list(map(int, input().split()))\n\ns=[list(map(int, input().split())) for _ in range(M)]\n\na=["a" for _ in range(N)]\n\nif len(s)==0 and N==1:\n print(0)\n sys.exit()\n \nelif len(s)==0:\n print(10**(N-1))\n sys.exit()\n\nfor i in s:\n if i[1]==0 and i[0]==1 and N!=1:\n print(-1)\n sys.exit()\n \n if a[i[0]-1]=="a":\n a[i[0]-1]=str(i[1])\n \n elif a[i[0]-1]!="a" and a[i[0]-1]==str(i[1]):\n continue\n \n elif a[i[0]-1]!="a" and a[i[0]-1]!=str(i[1]):\n print(-1)\n sys.exit()\n\nnum=[int(i) if i!="a" else 0 for i in a ]\n \nif N==1:\n print(int(num[-1]))\nelif N==2:\n ans=10*int(num[0])+int(num[1])\n if ans//10==0:\n ans+=10\n print(ans)\nelif N==3:\n ans=100*int(num[0])+10*int(num[1])+int(num[2])\n \n if ans//100==0:\n ans+=100\n print(ans) \n\n \n \n ']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s386587980', 's650412046', 's170703757']
[3064.0, 3064.0, 3064.0]
[20.0, 17.0, 18.0]
[1176, 1513, 868]
p02761
u247830763
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['import sys\nn,m = map(int,input().split())\nls = [list(map(int,input().split())) for i in range(m)]\na = []\nb = [0 for m in range(n)]\nprint(b)\nfor q in range(m):\n if ls[q][0] == 1:\n print("Hi")\n if ls[q][1] == 0:\n if n != 1:\n print(-1)\n sys.exit()\n else:\n print(0)\n sys.exit()\n else:\n b[0] = ls[q][1]\nfor j in range(2,n+1):\n for k in range(m):\n if ls[k][0] == j:\n a.append(ls[k][1])\n else:\n continue\n if len(set(a)) ==1:\n c = list(a)\n b[j-1] = c[0]\n elif len(set(a)) >1:\n print(-1)\n sys.exit()\nt = "".join(map(str,b))\nprint(t)', 'import sys\nn,m = map(int,input().split())\ninf = float("inf")\nls = [-inf]*n\nfor i in range(m):\n a,b = map(int,input().split())\n if ls[a-1] == -inf:\n ls[a-1] = b\n elif ls[a-1] != b:\n print(-1)\n sys.exit()\nif ls[0] == 0:\n if n != 1:\n print(-1)\n sys.exit()\n else:\n print(0)\n sys.exit()\nfor j in range(n):\n if ls[j] == -inf:\n if j == 0 and n == 1:\n print(0)\n sys.exit()\n elif j == 0 and n != 1:\n ls[j] = 1\n else:\n ls[j] = 0\nls = list(map(str,ls))\nprint("".join(ls))\n \n ']
['Wrong Answer', 'Accepted']
['s346191054', 's816468628']
[3064.0, 3064.0]
[17.0, 17.0]
[737, 606]
p02761
u248670337
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n,m=map(int,input().split())\nN="a"*n\nfor _ in range(m):\n s,c=map(int,input().split())\n s-=1\n if (s==0 and c==0) or (N[s]!="a" and N[s]!=str(c)):\n print(-1)\n exit() \n else:\n N=N[:s]+str(c)+N[s+1:]\nprint(N)\nif N[0]=="a":N="1"+N[1:]\nN=N.replace("a","0")\nprint(int(N))', 'n,m=map(int,input().split())\nN="a"*n\nfor _ in range(m):\n s,c=map(int,input().split())\n s-=1\n if (s==0 and c==0 and n!=1) or (N[s]!="a" and N[s]!=str(c)):\n print(-1)\n exit() \n else:\n N=N[:s]+str(c)+N[s+1:]\nif N[0]=="a" and n!=1:N="1"+N[1:]\nN=N.replace("a","0")\nprint(int(N))']
['Wrong Answer', 'Accepted']
['s514319354', 's484487976']
[3064.0, 3064.0]
[17.0, 17.0]
[304, 313]
p02761
u250583425
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["import sys\ndef input(): return sys.stdin.readline().rstrip()\n\ndef main():\n N, M = map(int, input().split())\n sc = [tuple(map(int, input().split())) for _ in range(M)]\n ans = [-1] * N\n for i in range(N):\n for s, c in sc:\n if s == i + 1:\n if ans[i] == -1:\n ans[i] = c\n else:\n print(-1)\n exit()\n \n if ans[i] == -1:\n if i == 0:\n ans[i] = 1\n else:\n ans[i] = 0\n ans_v = int(''.join(map(str, ans)))\n if len(str(ans_v)) == N:\n print(ans_v)\n else:\n print(-1)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\ndef input(): return sys.stdin.readline().rstrip()\n\ndef main():\n N, M = map(int, input().split())\n sc = [tuple(map(int, input().split())) for _ in range(M)]\n ans = [-1] * N\n for i in range(N):\n for s, c in sc:\n if s == i + 1:\n if ans[i] == -1:\n ans[i] = c\n else:\n if ans[i] == c:\n continue\n else:\n print(-1)\n exit()\n \n if ans[i] == -1:\n if i == 0 and N > 1:\n ans[i] = 1\n else:\n ans[i] = 0\n ans_v = int(''.join(map(str, ans)))\n if len(str(ans_v)) == N:\n print(ans_v)\n else:\n print(-1)\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s433485219', 's310279524']
[3064.0, 3064.0]
[18.0, 17.0]
[704, 816]
p02761
u252828980
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n,m = map(int,input().split())\nL = [-1]*n\nlia,lib = [],[]\nflag = True\n\nfor i in range(m):\n a,b = map(int,input().split())\n lia.append(a-1)\n lib.append(b)\n#print(lia,lib)\nfor i in range(len(lia)):\n if L[i] == -1:\n L[lia[i]] = lib[i]\n if L[i] != -1:\n print(-1)\n exit()\n\nif n == 1:\n if L[0] != -1:\n print(L[0])\n exit()\nelse:\n if L[0] == 0:\n print(-1)\n exit()\n elif L[0] == -1:\n L[0] = 1\n \nfor i in range(n):\n if L[i] == -1:\n L[i] = 0\nL = [str(x) for x in L]\nprint("".join(L))', ' = [-1]*n\nli = []\nflag = True\n\nfor i in range(m):\n a,b = map(int,input().split())\n if n == 1:\n if a == 1:\n L[0] = b\n break\n else:\n flag = False\n else:\n if (a in li) and L[a-1] != b:\n flag = False\n break\n elif a == 1 and b == 0:\n flag = False\n break\n else:\n L[a-1] = b\n li.append(a)\nfor i in range(n):\n if L[i] == -1:\n L[i] = 0\nif flag:\n L = [str(x) for x in L]\n print("".join(L))\nelse:\n print(-1)', '#n = int(input())\nn,m = map(int,input().split())\n#L= list(map(int, input().split()))\nL = []\nfor i in range(m):\n a = list(map(int, input().split()))\n L.append(a)\n\nif n == 1:\n print(0)\n exit()\nif m == 0:\n print(-1)\ns = [-1]*n\nfor i in range(m):\n s[L[i][0]-1] = L[i][1]\nprint(L,s)\nif s[0] == 0:\n print(-1)\n exit()\n\nfor i in range(1,m):\n if s[i]==-1:\n s[i] = 0\n print(s)\nans = ""\nfor i in range(m):\n ans += str(s[i])\nprint(int(ans))', 'n,m = map(int,input().split())\nL = []\nfor i in range(m):\n L.append(list((map(int,input().split()))))\n\nfor i in range(1000):\n p = str(i)\n flag = False\n for j in range(m):\n if len(p) >= L[j][0]:\n if int(p[L[j][0]-1]) != L[j][1]:\n break\n else:\n if len(p) == n:\n flag = True\n\n if flag:\n print(i)\n exit()\nprint(-1)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s573637431', 's635111560', 's712997879', 's590470717']
[3064.0, 2940.0, 3064.0, 3064.0]
[17.0, 17.0, 17.0, 18.0]
[565, 558, 468, 392]
p02761
u253799217
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["N, M = list(map(int, input().split(' ')))\nr = [ None for i in range(N) ]\nduplicated = False\nfor i in range(M):\n s, c = list(map(int, input().split(' ')))\n if r[s-1] is not None:\n\tduplicated = True\n break\n r[s-1] = c\n\nif duplicated:\n for i in range(N):\n if r[i] is None:\n r[i] = 0\n v = sum(r[i] * 10**i for i in range(N))\n print(v)\nelse:\n print(-1)\n", "N, M = list(map(int, input().split(' ')))\nr = [ None for i in range(N) ]\n\nillegal = False\nfor i in range(M):\n s, c = list(map(int, input().split(' ')))\n if r[s-1] is not None and r[s-1] != c:\n illegal = True\n break\n r[s-1] = c\n\nv = -1\nif not illegal:\n for i in range(N):\n if r[i] is None:\n if i == 0 and N != 1:\n r[i] = 1\n else:\n r[i] = 0\n v = sum(r[i] * 10**i for i in range(N))\n if v < 10**(N-1) and not (N == 1 and v == 0):\n v = -1\n\nprint(v)", "N, M = list(map(int, input().split(' ')))\nr = [ None for i in range(N) ]\n\nillegal = False\nfor i in range(M):\n s, c = list(map(int, input().split(' ')))\n if r[s-1] is not None and r[s-1] != c:\n illegal = True\n break\n r[s-1] = c\n\nv = -1\nif not illegal:\n for i in range(N):\n if r[i] is None:\n r[i] = 0\n v = sum(r[i] * 10**i for i in range(N))\n if v != 0 and v < 10**(N-1):\n v = -1\n\nprint(v)", "N, M = list(map(int, input().split(' ')))\nr = [ None for i in range(N) ]\nduplicated = False\nfor i in range(M):\n s, c = list(map(int, input().split(' ')))\n if r[s-1] is not None:\n\tduplicated = True\n break\n r[s-1] = c\n\nif not duplicated:\n for i in range(N):\n if r[i] is None:\n r[i] = 0\n v = sum(r[i] * 10**i for i in range(N))\n print(v)\nelse:\n print(-1)\n", "N, M = list(map(int, input().split(' ')))\nr = [ None for i in range(N) ]\nduplicated = False\nfor i in range(M):\n s, c = list(map(int, input().split(' ')))\n if r[s-1] is not None:\n\tduplicated = True\n break\n r[s-1] = c\n\nv = -1\nif not duplicated:\n for i in range(N):\n if r[i] is None:\n r[i] = 0\n v = sum(r[i] * 10**i for i in range(N))\n if v < 100:\n v = -1\n\nprint(v)\n", " N, M = list(map(int, input().split(' ')))\n r = [ None for i in range(N) ]\n \n illegal = False\n for i in range(M):\n s, c = list(map(int, input().split(' ')))\n if r[s-1] is not None and r[s-1] != c:\n illegal = True\n break\n r[s-1] = c\n \n v = -1\n if not illegal:\n for i in range(N):\n if r[i] is None:\n if i == 0 and N != 1:\n r[i] = 1\n else:\n r[i] = 0\n v = sum(r[i] * 10**i for i in range(N))\n if v < 10**(N-1) and not (N == 1 and v == 0):\n v = -1\n \n print(v)", "N, M = list(map(int, input().split(' ')))\nr = [ None for i in range(N) ]\n\nillegal = False\nfor i in range(M):\n s, c = list(map(int, input().split(' ')))\n if r[s-1] is not None and r[s-1] != c:\n illegal = True\n break\n r[s-1] = c\n\nv = -1\nif not illegal:\n for i in range(N):\n if r[i] is None:\n if i == 0:\n r[i] = 1\n else:\n r[i] = 0\n v = sum(r[i] * 10**i for i in range(N))\n if v < 10**(N-1) and not (N == 1 and v == 0):\n v = -1\n\nprint(v)", "N, M = list(map(int, input().split(' ')))\nr = [ None for i in range(N) ]\n\nduplicated = False\nfor i in range(M):\n s, c = list(map(int, input().split(' ')))\n if r[s-1] is not None:\n duplicated = True\n break\n r[s-1] = c\n\nv = -1\nif not duplicated:\n for i in range(N):\n if r[i] is None:\n r[i] = 0\n v = sum(r[i] * 10**i for i in range(N))\n if v != 0 and v < 10**(N-1):\n v = -1\n\nprint(v)\n", "N, M = list(map(int, input().split(' ')))\nr = [ None for i in range(N) ]\n\nillegal = False\nfor i in range(M):\n s, c = list(map(int, input().split(' ')))\n if r[s-1] is not None and r[s-1] != c:\n illegal = True\n break\n r[s-1] = c\n\nv = -1\nif not illegal:\n for i in range(N):\n if r[i] is None:\n r[i] = 0\n v = sum(r[i] * 10**i for i in range(N))\n if v < 10**(N-1) and not (N == 1 and v == 0):\n v = -1\n\nprint(v)", "N, M = list(map(int, input().split(' ')))\nr = [ None for i in range(N) ]\n\nduplicated = False\nfor i in range(M):\n s, c = list(map(int, input().split(' ')))\n if r[s-1] is not None:\n duplicated = True\n break\n r[s-1] = c\n\nv = -1\nif not duplicated:\n for i in range(N):\n if r[i] is None:\n r[i] = 0\n v = sum(r[i] * 10**i for i in range(N))\n if v < 100:\n v = -1\n\nprint(v)\n", "N, M = list(map(int, input().split(' ')))\nr = [ None for i in range(N) ]\n\nillegal = False\nfor i in range(M):\n s, c = list(map(int, input().split(' ')))\n if r[s-1] is not None and r[s-1] != c:\n illegal = True\n break\n r[s-1] = c\n\nv = -1\nif not illegal:\n for i in range(N):\n if r[i] is None:\n if i == 0 and N != 1:\n r[i] = 1\n else:\n r[i] = 0\n v = sum(r[i] * 10**(N-1-i) for i in range(N))\n if v < 10**(N-1) and not (N == 1 and v == 0):\n v = -1\n\nprint(v)"]
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s056754975', 's101270589', 's173064155', 's329655341', 's348431645', 's361885681', 's659920813', 's688476805', 's707896696', 's867063467', 's776686176']
[2940.0, 3064.0, 3064.0, 2940.0, 2940.0, 2940.0, 3192.0, 3064.0, 3064.0, 3064.0, 3064.0]
[17.0, 18.0, 18.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 18.0]
[366, 486, 410, 370, 383, 585, 475, 404, 427, 387, 492]
p02761
u254221913
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["n,m = map(int,input().split())\ns = [0] * m\nc = [0] * m\nans = [0] * n\nflg = [0] * n\nfor i in range(m):\n s[i],c[i] = map(int,input().split())\nfor j in range(m):\n if: flg[s[j]-1] == 1 and ans[s[j]-1] != c[j]:\n print(-1)\n exit()\n else:\n ans[s[j]-1] = c[j]\n flg[s[j]-1] = 1\n \nif n > 1 and ans[0] == 0 :\n print(-1)\nelse:\n print(''.join(map(str,ans)))\n", "n,m = map(int,input().split())\ns = [0] * m\nc = [0] * m\nans = [0] * n\nflg = [0] * n\nfor i in range(m):\n s[i],c[i] = map(int,input().split())\nfor j in range(m):\n if flg[s[j]-1] == 1 and ans[s[j]-1] != c[j]:\n print(-1)\n exit()\n else:\n ans[s[j]-1] = c[j]\n flg[s[j]-1] = 1\n \nif n > 1 and flg[0] == 1 and ans[0] == 0 :\n print(-1)\nelif n > 1 and flg[0] == 0:\n ans[0] = 1\n print(''.join(map(str,ans)))\n exit()\nelse:\n print(''.join(map(str,ans)))"]
['Runtime Error', 'Accepted']
['s619900337', 's867584896']
[2940.0, 3064.0]
[17.0, 17.0]
[391, 492]
p02761
u254871849
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["import sys\n\nn, m, *sc = map(int, sys.stdin.read().split())\nsc = zip(*[iter(sc)] * 2)\n\ndef main():\n res = [0] * n\n determined = set() \n\n for s, c in sc:\n if s in determined:\n return -1\n else:\n res[s-1] = c\n determined.add(s)\n\n if not res[0]:\n return -1\n\n res = ''.join([str(d) for d in res])\n return res\n\nif __name__ == '__main__':\n ans = main()\n print(ans)", "import sys\n\nn, m, *sc = map(int, sys.stdin.read().split())\nsc = zip(*[iter(sc)] * 2)\n\ndef main():\n res = [0] * n\n determined = set() \n\n for s, c in sc:\n if s in determined:\n if res[s-1] != c:\n return -1\n else:\n res[s-1] = c\n determined.add(s)\n\n if n > 1 and not res[0] == 0:\n return -1\n\n res = ''.join([str(d) for d in res])\n return res\n\nif __name__ == '__main__':\n ans = main()\n print(ans)", "import sys\n\nn, m, *sc = map(int, sys.stdin.read().split())\nsc = zip(*[iter(sc)] * 2)\n\ndef main():\n a = [0] * n\n b = [0] * n\n for s, c in sc:\n s -= 1\n if b[s] and a[s] != c:\n print(-1); return\n elif s == c == 0 and n > 1:\n print(-1); return\n b[s] = 1\n a[s] = c\n if not b[0] and n > 1: a[0] = 1\n print(''.join(map(str, a)))\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s135722667', 's562584079', 's149083038']
[3064.0, 3064.0, 3064.0]
[18.0, 17.0, 17.0]
[434, 483, 433]
p02761
u255821449
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['# -*- coding: utf-8 -*-\n\nN, M = map(int, input().split())\nresult = [-1] * N\n\nif M == 0:\n\n\nfor i in range(1, M + 1):\n s, c = map(int, input().split())\n if result[s - 1] == -1:\n result[s - 1] = c\n elif result[s - 1] == c:\n continue\n else:\n print(-1)\n exit(0)\n\nif N != 1 and result[0] == 0:\n print(-1)\n exit(0)\n\nif N == 1 and result[0] == -1:\n print(0)\n exit(0)\n\nif N != 1 and result[0] == -1:\n result[0] = 1\n\nfor i in range(len(result)):\n if result[i] == -1:\n print(0, end="")\n else:\n print(result[i], end="")\nprint()\n', '# -*- coding: utf-8 -*-\n\nN, M = map(int, input().split())\nresult = [-1] * N\n\nfor i in range(1, M + 1):\n s, c = map(int, input().split())\n if result[s - 1] == -1:\n result[s - 1] = c\n elif result[s - 1] == c:\n continue\n else:\n print(-1)\n exit(0)\n\nif N != 1 and result[0] == 0:\n print(-1)\n exit(0)\n\nif N == 1 and result[0] == -1:\n print(0)\n exit(0)\n\nif N != 1 and result[0] == -1:\n result[0] = 1\n\nfor i in range(len(result)):\n if result[i] == -1:\n print(0, end="")\n else:\n print(result[i], end="")\nprint()\n']
['Runtime Error', 'Accepted']
['s438876167', 's792542787']
[3064.0, 3064.0]
[19.0, 17.0]
[591, 578]
p02761
u265506056
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['print(0)', 'print(-1)', 'N,M=map(int,input().split())\nans=[0]*N\nguess=0\nnum=0\nS=[]\nC=[]\nfor _ in range(M):\n s,c=map(int,input().split())\n S.append(s)\n C.append(c)\nfor i in range(M):\n s=S[i]\n c=C[i]\n if ans[s-1]!=0 and ans[s-1]!=c:\n guess=1\n break\n elif s==1 and c==0:\n if N!=1:\n guess=1\n break\n else:\n ans[s-1]=c\nif guess==0:\n if ans[0]==0:\n if N!=1:\n ans[0]=1\n for i in range(N):\n num+=ans[i]*(10**(N-1-i))\n print(num)\nelse:\n print(-1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s697938790', 's902291722', 's962863647']
[2940.0, 2940.0, 3064.0]
[17.0, 18.0, 17.0]
[8, 9, 522]
p02761
u267300160
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N,M = map(int,input().split())\nvalues = []\nfor i in range(N):\n values.append([])\nfor i in range(M):\n s,c = map(int,input().split())\n values[s-1].append(c)\nfor i in range(N):\n if values[i] == list():\n if N == 2:\n values[0].append(1)\n elif N == 3:\n values[0].append(1)\n values[i].append(0)\nfor i in range(1000):\n i = [int(j) for j in list(str(i))]\n if len(i) != N:\n continue\n if N==3:\n if i[0] in values[0] and i[1] in values[1] and i[2] in values[2]:\n print("".join([str(j) for j in i]))\n exit()\n elif N==2:\n if i[0] in values[0] and i[1] in values[1]:\n print("".join([str(j) for j in i]))\n exit()\n else:\n if i[0] in values[0]:\n print("".join([str(j) for j in i]))\n exit()\nprint(-1)\n\n', 'N,M = map(int,input().split())\nans = [0] * N\nsc = []\nfor i in range(M):\n s,c = map(int,input().split())\n sc.append((s,c))\nsc.sort()\nsc = list(set(sc))\nfor s,c in sc:\n ans[s-1] = c\nif N != 1 and ans[0] == 0:\n print(-1)\nelse:\n print(ans)\n', 'N,M = map(int,input().split())\nvalues = []\nfor i in range(N):\n values.append([])\nfor i in range(M):\n s,c = map(int,input().split())\n values[s-1].append(c)\n\n\nfor i in values:\n if len(set(i)) >= 2:\n print(-1)\n exit()\n\n\nif values[0] == list():\n if N != 1:\n values[0].append(1)\n\n\nfor i in range(N):\n if len(values[i]) == 0:\n values[i].append(0)\n\n\nfor i in range(1000):\n i = [int(j) for j in list(str(i))]\n if len(i) != N:\n continue\n if N==3:\n if i[0] in values[0] and i[1] in values[1] and i[2] in values[2]:\n print("".join([str(j) for j in i]))\n exit()\n elif N==2:\n if i[0] in values[0] and i[1] in values[1]:\n print("".join([str(j) for j in i]))\n exit()\n else:\n if i[0] in values[0]:\n print("".join([str(j) for j in i]))\n exit()\nprint(-1)\n\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s055151637', 's516697409', 's616755875']
[3064.0, 3060.0, 3064.0]
[18.0, 17.0, 19.0]
[847, 251, 1028]
p02761
u267718666
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["N, M = map(int, input().split())\nSC = [list(map(int, input().split())) for _ in range(M)]\nD = {}\nans = ['0'] * N\nans[0] = '1'\nfor i in range(M):\n if SC[i][0] not in D:\n D[SC[i][0]] = SC[i][1]\n else:\n if D[SC[i][0]] != SC[i][1]:\n print(-1)\n exit()\n\nfor k, v in D.items():\n ans[k-1] = str(v)\n\nans = -1 if ans[0] == '0' else int(''.join(ans))\nprint(as)\n", 'N, M = map(int, input().split())\nSC = [list(map(int, input().split())) for _ in range(M)]\nfor n in range(10**N):\n n = str(n)\n if len(n) != N:\n continue\n if all([n[SC[i][0]-1] == str(SC[i][1]) for i in range(M)]):\n print(n)\n exit()\n\nprint(-1)']
['Runtime Error', 'Accepted']
['s143956570', 's590578778']
[9056.0, 9120.0]
[24.0, 29.0]
[395, 271]
p02761
u268318377
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n, m = map(int, input().split())\nS, C = []\nfor _ in range(m):\n s, c = map(int, input().split())\n S.append(s)\n C.append(c)\n \nfor num in range(10 ** (max(S) - 1), 10 ** n):\n num = str(num)\n f = 1\n for s, c in zip(S, C):\n s = s - 1\n if int(num[s]) != c:\n f = 0\n break\n \n if f:\n ans = num\n break\n \nprint(ans)', 'print(0)', 'n, m = map(int, input().split())\nnums = {1:None, 2:None, 3:None}\nans = 0\n \nfor _ in range(m):\n s, c = map(int, input().split())\n if nums[s] == None:\n nums[s] = c\n else:\n if nums[s] != c:\n ans = -1\n break\n else:\n continue\n\nif n == 1 and m == 0:\n print(0)\nelif ans == -1:\n pass\nelse:\n for k, v in nums.items():\n if v == None:\n nums[k] = 0\n elif k == 1 and v == 0:\n ans = -1\n break\n if ans != -1:\n for number in range([0, 10, 100][n-1], 10**n):\n number = str(number)\n if all(int(i)==int(j) for i, j in zip(nums.values(), number)):\n asn = number\n break\n else:\n continue\n\nprint(ans)', "n, m = map(int, input().split())\n \nnum = [-1] * n\nans = -1\nf = 1\n \nfor _ in range(m):\n s, c = map(int, input().split())\n if s == 1 and c == 0:\n if n == 1:\n ans = 0\n f = 0\n break\n \n i = num[s - 1]\n if i == -1:\n num[s-1] = c\n elif i == c:\n continue\n else:\n f = 0\n break\n \nif num[0] == -1:\n if n == 1:\n num[0] = 0\n else:\n num[0] = 1\n \nif f:\n num = [0 if n == -1 else n for n in num]\n ans = ''.join(map(str, num))\n \nprint(ans)"]
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s312470417', 's361825712', 's557233904', 's914504074']
[3188.0, 2940.0, 3064.0, 3064.0]
[18.0, 17.0, 19.0, 17.0]
[342, 8, 784, 470]
p02761
u272075541
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n,m = map(int, input().split())\na = [input() for _ in range(m)]\nb = set(a)\nc = [list(map(int, ai.split())) for ai in a]\nd = dict(c)\n\nif len(d) != len(b):\n print(-1)\nelse:\n if n == 1:\n print(d[0])\n else:\n if d[0] == 0:\n print(-1)\n else:\n ans = ["0"] * n\n for k in d:\n ans[k-1] = str(d[k])\n print("".join(ans))\n', 'n,m = map(int, input().split())\na = [input() for _ in range(m)]\n\nx = 10 ** (n - 1)\nif n == 1: x = 0\nans = [-1]\n\nwhile x < 10 ** n:\n s = str(x)\n if all(s[int(ai[0]) - 1] == ai[2] for ai in a):\n ans.append(x)\n break\n x += 1\n\nprint(ans[-1])']
['Runtime Error', 'Accepted']
['s064352606', 's185911721']
[3064.0, 3064.0]
[17.0, 19.0]
[398, 260]
p02761
u273345915
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N,M=map(int,input().split())\narr=[list(map(int,input().split())) for _ in range(M)]\n\nfor x in range(0, 1000):\n nx=x//10\n d=[x%10]\n while(nx):\n d.append(nx%10)\n nx//=10\n d.reverse\n\n if len(d)!=N: continue\n\n chk=True\n for i in range(M):\n if(d[arr[i][0]-1]!=arr[i][1]): chk=False\n if chk: print(x);exit()\n\nprint(-1)', 'N,M=map(int,input().split())\narr=[list(map(int,input().split())) for _ in range(M)]\n\nfor x in range(0, 1000):\n nx=x//10\n d=[x%10]\n while(nx):\n d.append(nx%10)\n nx//=10\n\n d.reverse()\n\n if len(d)!=N: continue\n\n chk=True\n for i in range(M):\n if(d[arr[i][0]-1]!=arr[i][1]): chk=False\n if chk: print(x);exit()\n\nprint(-1)']
['Wrong Answer', 'Accepted']
['s810668230', 's614130219']
[3064.0, 3064.0]
[18.0, 19.0]
[357, 360]
p02761
u274635633
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n,m=map(int,input().split())\nx=0\ns=[list(map(int,input().split())) for i in range(m)]\ns=sorted(s)\nfor i in range(m):\n if s[i][0]==1 and s[i][1]==0:\n x=-1\n\nfor i in range(m):\n for j in range(m):\n if s[i][0]==s[j][0] and s[i][1]!=s[j][1]:\n x=-1\n\na=[0]*n\nfor i in range(m):\n a[s[i][0]]=s[i][1]\n\nfor i in range(m):\n ans=a[i]*10**(n-i-1)\nif a[0]==0:\n ans+=100\nprint(x,ans)', "n,m=map(int,input().split())\nsc=[list(map(int,input().split())) for i in range(m)]\nif n==1:\n start=0\n goal=10\nelse:\n start=10**(n-1)\n goal=10**n\nans=-1\nfor i in range(start,goal):\n x='0'+str(i)\n ok=True\n for j in range(m):\n if x[sc[j][0]] != str(sc[j][1]):\n ok=False\n if ok:\n ans=i\n break\nprint(ans)"]
['Runtime Error', 'Accepted']
['s935076929', 's896839293']
[3064.0, 3064.0]
[18.0, 18.0]
[383, 321]
p02761
u276204978
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["import numpy as np\n\nN, M = map(int, input().split())\n\nl = [list(map(int, input().split())) for i in range(M)]\n\nr = np.zeros(3)\nr -= 1\n\nf = True\nfor i, j in l:\n i -= 1\n if N == i and j == 0:\n f = False\n if r[i] == -1:\n r[i] = j\n if r[i] != -1 and r[i] != j:\n f = False\nprint(r)\nif f:\n l = [str(int(max(i, 0))) for i in r]\n print(''.join(l))\nelse:\n print(-1)", "import numpy as np\n\nN, M = map(int, input().split())\n\nl = [list(map(int, input().split())) for i in range(M)]\n\nr = np.zeros(3)\nr -= 1\n\nf = True\nfor i, j in l:\n i -= 1\n if i == 0 and j == 0:\n f = False\n if r[i] == -1:\n r[i] = j\n if r[i] != -1 and r[i] != j:\n f = False\nprint(r)\nif f:\n l = [str(int(max(i, 0))) for i in r]\n print(''.join(l))\nelse:\n print(-1)", "import numpy as np\n\nN, M = map(int, input().split())\n\nl = [list(map(int, input().split())) for i in range(M)]\n\nr = np.zeros(3)\nr -= 1\n\nf = True\nfor i, j in l:\n i -= 1\n if N < i+1:\n f = False\n continue\n if N != 1 and i == 0 and j == 0:\n f = False\n continue\n if r[i] != -1 and r[i] != j:\n f = False\n continue\n if r[i] == -1:\n r[i] = j\n l = ['1' if i == 0 and j == -1 else str(int(max(j, 0))) for i, j in enumerate(r)]\n s = ''.join(l)\n if N == 3:\n\t print(s)\n if N == 2:\n \tprint(s[:2])\n if N == 1:\n print(s[:1])\nelse:\n print(-1)", "import numpy as np\n\nN, M = map(int, input().split())\n\nl = [list(map(int, input().split())) for i in range(M)]\n\nr = np.zeros(3)\nr -= 1\n\nf = True\nfor i, j in l:\n i -= 1\n if N < i+1:\n f = False\n continue\n if N != 1 and i == 0 and j == 0:\n f = False\n continue\n if r[i] != -1 and r[i] != j:\n f = False\n continue\n if r[i] == -1:\n r[i] = j\nif f:\n l = ['1' if i == 0 and j == -1 else str(int(max(j, 0))) for i, j in enumerate(r)]\n s = ''.join(l)\n if N == 3:\n\t print(s)\n elif N == 2:\n \tprint(s[:2])\n elif N == 1 and M == 0:\n print(0)\n else:\n print(s[:1])\nelse:\n print(-1)\n"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s429466903', 's583127399', 's821738821', 's329874980']
[13716.0, 12428.0, 12500.0, 12504.0]
[151.0, 151.0, 148.0, 149.0]
[398, 398, 621, 670]
p02761
u277312083
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n, m = map(int, input().split())\nsc = [[0, 0]] * m\nfor i in range(m):\n sc[i][0], sc[i][1] = map(int, input().split())\nsorted(sc)\n\ndef checker():\n if m == 0:\n if n == 1:\n return 0\n else:\n return -1\n for i in range(1, m):\n if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:\n return -1\n if n == 1:\n if sc[-1][0] == 1:\n return sc[0][1]\n elif n == 2:\n if sc[-1][0] == 1:\n return sc[0][1] * 10\n elif sc[0][0] == 2 and sc[-1][0] == 2:\n return 10 + sc[0][1]\n elif sc[0][0] == 1 and sc[-1][0] == 2:\n if sc[0][1] != 0:\n return sc[-1][1] + 10 * sc[0][1]\n elif n == 3:\n if sc[-1][0] == 1:\n return sc[0][1] * 100\n elif sc[-1][0] == 2:\n if sc[0][0] == 1:\n return 10 * sc[-1][0] + 100 * sc[0][1]\n else:\n return 100 + 10 * sc[-1][0]\n elif sc[-1][0] == 3:\n if sc[0][0] == 3:\n return 100 + sc[0][1]\n elif sc[0][0] == 2:\n return 100 + sc[-1][1] + 10 * sc[0][1]\n else:\n r1 = 0\n r2 = 0\n r3 = 0\n for i in range(m):\n if sc[i][0] == 1:\n r1 = sc[i][1]\n elif sc[i][0] == 2:\n r2 = sc[i][1]\n elif sc[i][0] == 3:\n r3 = sc[i][1]\n return 100 * r1 + 10 * r2 + r3\n return -1\n\nprint(checker())\n', 'n, m = map(int, input().split())\nsc = [list(map(int, input().split())) for i in range(m)]\nsorted(sc)\n\ndef f1():\n if m == 0:\n return 0\n for i in range(1, m):\n if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:\n return -1\n return sc[0][1]\n\ndef f2():\n if m == 0:\n return 10\n for i in range(1, m):\n if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:\n return -1\n l = [10 * i + j for i in range(1, 10) for j in range(0, 10)]\n sl = ["1", "0"]\n for i in range(m):\n sl[sc[i][0] - 1] = str(sc[i][1])\n s = sl[0] + sl[1]\n for i in l:\n if str(i) == s:\n return i\n return -1\n\ndef f3():\n if m == 0:\n return 100\n for i in range(1, m):\n if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:\n return -1\n l = [100 * i + 10 * j + k for i in range(1, 10) for j in range(0, 10) for k in range(0, 10)]\n sl = ["1", "0", "0"]\n for i in range(m):\n sl[sc[i][0] - 1] = str(sc[i][1])\n s = sl[0] + sl[1] + sl[2]\n for i in l:\n if str(i) == s:\n return i\n return -1\n\nif n == 1:\n print(f1())\nelif n == 2:\n print(f2())\nelse:\n print(f3())\n']
['Wrong Answer', 'Accepted']
['s854857049', 's106690217']
[3192.0, 3188.0]
[18.0, 19.0]
[1577, 1211]
p02761
u278356323
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["# ABC157c\n\n\ndef main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**6)\n \n\n n, m = map(int, input().split())\n con = [list(map(int, input().split())) for _ in range(m)]\n num = ['a'] * n\n for s, c in con:\n if num[s - 1] == 'a' or num[s - 1] == c:\n num[s - 1] = str(c)\n continue\n print(-1)\n exit(0)\n for i in range(n):\n if num[i] == 'a':\n if i == 0:\n num[i] = '1'\n else:\n num[i] = '0'\n if num[0] == '0':\n print(-1)\n exit(0)\n print(*num, sep='')\n\n\nif __name__ == '__main__':\n main()\n", "# ABC157c\n\n\ndef main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**6)\n \n\n n, m = map(int, input().split())\n con = [list(map(int, input().split())) for _ in range(m)]\n s = 10 ** (n - 1)\n if s == 1:\n s -= 1\n\n for i in range(s, 10 ** (n + 1)):\n falg = False\n num = list(str(i))\n for s, c in con:\n if num[s - 1] != str(c):\n falg = True\n break\n if falg:\n continue\n print(*num, sep='')\n exit(0)\n print(-1)\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s190167070', 's203767766']
[3064.0, 3064.0]
[17.0, 24.0]
[707, 649]
p02761
u279266699
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["def main():\n n, m = map(int, input().split())\n ans = [0] * n\n count = [0] * n\n for i in range(m):\n s, c = map(int, input().split())\n if s == 1 and c == 0:\n print(-1)\n exit()\n if count[s - 1] == 0:\n ans[s - 1] = c\n count[s - 1] += 1\n else:\n print(-1)\n exit()\n if ans[0] == 0:\n ans[0] = 1\n print(''.join(map(str, ans)))\n\n\nif __name__ == '__main__':\n main()\n", "\n# n, m = map(int, input().split())\n# ans = [0] * n\n# count = [0] * n\n\n# s, c = map(int, input().split())\n# if s == 1 and c == 0 and n != 1:\n# print(-1)\n# exit()\n# if count[s - 1] == 0 or ans[s - 1] == c:\n# ans[s - 1] = c\n# count[s - 1] += 1\n# else:\n# print(-1)\n# exit()\n# if ans[0] == 0 and n != 1:\n# ans[0] = 1\n# print(''.join(map(str, ans)))\n\n\n# if __name__ == '__main__':\n# main()\n\ndef main():\n n, m = map(int, input().split())\n C = [-1] * n\n flag = 0\n for i in range(m):\n s, c = map(int, input().split())\n if C[s - 1] == -1 or C[s - 1] == c:\n C[s - 1] = c\n else:\n flag = 1\n\n if flag or (C[0] == 0 and n != 1):\n print(-1)\n return\n\n else:\n C = [0 if i == -1 else i for i in C]\n if C[0] == 0 and n != 1:\n C[0] = 1\n print(''.join(list(map(str, C))))\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s557370432', 's138127846']
[3064.0, 9216.0]
[17.0, 26.0]
[477, 1067]
p02761
u280853184
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['import sys\nN,M=map(int,input().split())\nsc=[-1]*N\nfor _ in range(M):\n s,c=map(int,input().split())\n if sc[s-1]==-1 and sc[s-1]>c:\n sc[s-1]=c\n elif sc[s-1]!=-1 and sc[s-1]!=c:\n print("-1")\n sys.exit(0)\nfor i in range(N):\n if sc[i]==-1:\n sc[i]=0\nif sc[0]==0 and N!=1:\n print("-1")\n sys.exit(0)\nelif sc[0]==0 and N==1:\n print("0")\n sys.exit(0)\n\nfor i in range(N):\n if sc[i]!=0:\n break\n else:\n if i==N-1:\n print("-1")\n sys.exit(0)\nprint((\'\'.join(map(str, sc))))\n', 'import sys\nN,M=map(int,input().split())\nsc=[-1]*N\nfor _ in range(M):\n s,c=map(int,input().split())\n if sc[s-1]==-1:\n sc[s-1]=c\n elif sc[s-1]!=c:\n print("-1")\n sys.exit(0)\n \nif sc[0]==-1 and N!=1:\n sc[0]=1\nelif sc[0]==-1 and N==1:\n print("0")\n sys.exit(0)\nelif sc[0]==0 and N==1:\n print("0")\n sys.exit(0)\nfor i in range(1,N):\n if sc[i]==-1:\n sc[i]=0\n\nfor i in range(N):\n if sc[i]!=0:\n break\n else:\n if i==N-1:\n print("-1")\n sys.exit(0)\nprint((\'\'.join(map(str, sc))))\n']
['Wrong Answer', 'Accepted']
['s341676368', 's098549142']
[3064.0, 3064.0]
[19.0, 18.0]
[496, 508]
p02761
u281610856
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["n, m = map(int, input().split())\nans = [0] * n\nans[0] = 1\ndata = [0] * m\nfor i in range(m):\n data[i] = list(map(int, input().split()))\narr = [0] * 3 \nfor j in range(m):\n s = data[j][0]-1\n c = data[j][1]\n before = ans[s]\n ans[s] = c\n after = ans[s]\n if before != after or after == 0:\n arr[s] += 1\nprint(arr)\nprint(ans)\nfor k in range(3):\n if arr[k] > 1: \n print(-1)\n exit()\nif ans[0] == 0 and n != 1: \n print(-1)\n exit()\nprint(*ans, sep='')", "import sys\ninput = sys.stdin.readline\n\n\ndef main():\n N, M = map(int, input().split())\n l = [tuple(map(int, input().split())) for _ in range(M)]\n l = list(set(l)) \n s_num = []\n if N == 1:\n ans = [0]\n for s, c in l:\n s -= 1\n if s in s_num:\n print(-1)\n exit()\n s_num.append(s)\n ans[s] = c\n else:\n ans = [1] + [0] * (N - 1)\n for s, c in l:\n s -= 1\n if s in s_num: \n print(-1)\n exit()\n if s == 0 and c == 0: \n print(-1)\n exit()\n s_num.append(s)\n ans[s] = c\n print(*ans, sep='')\n\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s727767500', 's812094756']
[3064.0, 3064.0]
[17.0, 18.0]
[582, 870]
p02761
u283929013
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N, M = map(int,input().split())\nS = []\nC = []\nflag = True\nfor i in range(M):\n s,c = map(int,input().split())\n if s in S:\n if C[S.index(s)] != c:\n flag = False\n break\n if s == M:\n if c == 0:\n flag = False\n break\n S.append(s)\n C.append(c)\n\nif flag:\n n = [1] + [0 for i in range(N - 1)]\n print(n)\n for i in range(len(S)):\n n[S[i]-1] = C[i]\n print(*n, sep="")\nelse:\n print("-1")', 'N, M = map(int,input().split())\nS = "0" * N\n\nfor i in range(M):\n s,c = map(int,input().split())\n if s == 1 and c == 0 and N != 1:\n print("-1")\n quit()\n elif S[s-1] == "0" or S[s-1] == str(c):\n S = S[0:s-1] + str(c) + S[s:-1]\n else:\n print("-1")\n quit()\n\nif S[0] == "0" and N != 1:\n S = "1" + S[1:-1]\n\nprint(S)', 'N, M = map(int,input().split())\nS = "0" * N\nfor i in range(M):\n s,c = map(int,input().split())\n if S[s-1] == "0" or S[s-1] == str(c):\n S = S[0:s-1] + str(c) + S[s:-1]\n print(S)\n else:\n print("-1")\n\nif S[0] == "0" and N != 1:\n S = "1" + S[1:-1]\n\nprint(S)', 'N, M = map(int,input().split())\nS = "0" * N\n\nfor i in range(M):\n s,c = map(int,input().split())\n if s == 1 and c == 0 and N != 1:\n print("-1")\n quit()\n elif S[s-1] == "0" or S[s-1] == str(c):\n S = S[0:s-1] + str(c) + S[s:]\n else:\n print("-1")\n quit()\n\nif S[0] == "0" and N != 1:\n S = "1" + S[1:]\n\nprint(S)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s134080078', 's726869889', 's903217696', 's757655270']
[3064.0, 3188.0, 3064.0, 3064.0]
[18.0, 20.0, 17.0, 17.0]
[469, 359, 286, 355]
p02761
u284363684
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['# input\nN, M = map(int, input().split())\n\nc = []\n\nc_append = c.append\n\nfor i in range(M):\n sm, cm = map(int, input().split())\n if (sm, cm) not in c:\n c_append((sm, cm))\n\nif (1, 0) in c or list(set([sm for sm, cm in c])) == [sm for sm, cm in c]:\n print(-1)\nelse:\n ans = -1\n\n \n for i in range(100, 1000):\n str_i = str(i)\n if False not in [int(str_i[sm - 1]) == cm for sm, cm in c]:\n ans = i\n break\n\n print(ans)\n', '# input\nN, M = map(int, input().split())\n\nc = []\n\nc_append = c.append\n\nfor i in range(M):\n sm, cm = map(int, input().split())\n if (sm, cm) not in c:\n c_append((sm, cm))\n \nif (1, 0) in c or len([sm for sm, cm in c]) >= 2:\n print(-1)\nelse:\n ans = -1\n \n \n for i in range(100, 1000):\n str_i = str(i)\n if False not in [int(str_i[sm - 1]) == cm for sm, cm in c]:\n ans = i\n break\n \n print(ans)', '# input\nN, M = map(int, input().split())\n\nc = []\n\nc_append = c.append\n\nfor i in range(M):\n sm, cm = map(int, input().split())\n c_append((sm, cm))\n\nif (1, 0) in c:\n print(-1)\nelse:\n ans = -1\n\n \n for i in range(1000):\n str_i = str(i)\n\n if N < len(str_i):\n break\n\n if False not in [int(str_i[sm - 1]) == cm for sm, cm in c]:\n ans = i\n break\n\n print(ans)', '# input\nN, M = map(int, input().split())\n\nc = []\n\nc_append = c.append\n\nfor i in range(M):\n sm, cm = map(int, input().split())\n c_append((sm, cm))\n\nans = -1\n\n\nfor i in range(1000):\n str_i = str(i)\n\n if N < len(str_i):\n break\n\n if N == len(str_i) and False not in [int(str_i[sm - 1]) == cm for sm, cm in c]:\n ans = i\n break\n\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s214381840', 's702226201', 's711666683', 's927009397']
[3064.0, 3064.0, 3064.0, 3064.0]
[18.0, 18.0, 18.0, 18.0]
[480, 478, 432, 376]
p02761
u289288647
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["import sys\nN, M = map(int, input().split())\n\nans = [0]*N\nans1 = [0]*N\nfor _ in range(M):\n a, b = map(int, input().split())\n if ans[a-1] != 0 and ans[a-1] != b:\n ans[a-1] = -1\n elif ans[a-1] == 0:\n ans[a-1] = b\n ans1[a-1] = 1\n print(ans)\n\nif -1 in ans:\n print('-1')\nelif sum(ans) == 0 and ans1[-1] == 1:\n print('0')\nelse:\n b = ''.join([str(i) for i in ans])\n if N == len(str(int(b))):\n print(int(b))\n else:\n for i, j in enumerate(ans):\n if i == N - len(str(int(b))):\n print(int(b))\n sys.exit()\n if ans1[i] == 1:\n print('-1')\n sys.exit()\n \n", "import sys\nN, M = map(int, input().split())\n\nans = [0]*N\nans1 = [0]*N\nfor _ in range(M):\n a, b = map(int, input().split())\n if ans[a-1] != 0 and ans[a-1] != b:\n ans[a-1] = -1\n elif ans[a-1] == 0:\n ans[a-1] = b\n ans1[a-1] = 1\n print(ans)\n\nif -1 in ans:\n print('-1')\nelif sum(ans) == 0 and ans1[-1] == 1:\n print('0')\nelse:\n b = ''.join([str(i) for i in ans])\n if N == len(str(int(b))):\n print(int(b))\n else:\n for i, j in enumerate(ans):\n if i == N - len(str(int(b))):\n print(int(b))\n sys.exit()\n if ans1[i] == 1:\n print('-1')\n sys.exit()\n \n", "import sys\nN, M = map(int, input().split())\n\nans = [0]*N\nans1 = [0]*N\nfor _ in range(M):\n a, b = map(int, input().split())\n if ans[a-1] != 0 and ans[a-1] != b:\n ans[a-1] = -1\n elif ans[a-1] == 0:\n ans[a-1] = b\n ans1[a-1] = 1\n print(ans)\n\nif -1 in ans:\n print('-1')\nelif (sum(ans) == 0 and ans1[-1] == 1) or (N == 1 and M == 0):\n print('0')\nelse:\n b = ''.join([str(i) for i in ans])\n if N == len(str(int(b))):\n print(int(b))\n else:\n for i, j in enumerate(ans):\n if i == N - len(str(int(b))):\n print(int(b))\n sys.exit()\n if ans1[i] == 1:\n print('-1')\n sys.exit()\n \n", "import sys\nN, M = map(int, input().split())\n\nans = [0]*N\nans1 = [0]*N\nfor _ in range(M):\n a, b = map(int, input().split())\n if ans[a-1] != 0 and ans[a-1] != b:\n ans[a-1] = -1\n elif ans[a-1] == 0:\n ans[a-1] = b\n ans1[a-1] = 1\n print(ans)\n\nif -1 in ans or M == 0:\n print('-1')\nelif sum(ans) == 0 and ans1[-1] == 1:\n print('0')\nelse:\n b = ''.join([str(i) for i in ans])\n if N == len(str(int(b))):\n print(int(b))\n else:\n for i, j in enumerate(ans):\n if i == N - len(str(int(b))):\n print(int(b))\n sys.exit()\n if ans1[i] == 1:\n print('-1')\n sys.exit()\n \n", "import sys\nN, M = map(int, input().split())\n\nans = [0]*N\nans1 = [0]*N\nfor _ in range(M):\n a, b = map(int, input().split())\n if ans[a-1] != 0 and ans[a-1] != b:\n ans[a-1] = -1\n elif ans[a-1] == 0:\n ans[a-1] = b\n ans1[a-1] = 1\n print(ans)\n\nif -1 in ans or M == 0:\n print('-1')\n#elif sum(ans) == 0 and ans1[-1] == 1:\n# print('0')\nelse:\n b = ''.join([str(i) for i in ans])\n if N == len(str(int(b))):\n print(int(b))\n else:\n for i, j in enumerate(ans):\n if i == N - len(str(int(b))):\n print(int(b))\n sys.exit()\n if ans1[i] == 1:\n print('-1')\n sys.exit()\n \n", "import sys\n\nn, m = map(int, input().split())\nnum = [-1]*n\n\nfor i in range(m):\n s,c = map(int, input().split())\n if num[s-1] != -1 and num[s-1] != c:\n print(-1)\n sys.exit()\n num[s-1] = c\n \nif n == 1 and num[0] == -1:\n num[0] = 0\nelif n != 1 and num[0] == -1:\n num[0] = 1\n\nnum = ['0' if x == -1 else str(x) for x in num]\n\nif len(str(int(''.join(num)))) == n:\n print(''.join(num))\nelse:\n print(-1)\n"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s145149826', 's204426753', 's405632474', 's576793683', 's661502230', 's483260003']
[9260.0, 9248.0, 9204.0, 9104.0, 9100.0, 9224.0]
[27.0, 26.0, 28.0, 28.0, 28.0, 31.0]
[685, 685, 710, 695, 697, 421]
p02761
u292849987
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["# coding:utf-8\n\nN, M = map(int, input().split(' '))\nans = ['-1' for _ in range(N)]\nfor _ in range(M):\n s, c = input().split(' ')\n if ans[int(s)-1] == '-1':\n ans[int(s)-1] = c\n elif ans[int(s)-1] == c:\n pass\n else:\n print('-1')\n exit(0)\n\nif ans[0] == '0' and len(ans) != 1:\n print('-1')\n exit(0)\n\nprint(ans)\noutput = ''\nfor el in ans:\n if output == '' and el == '-1':\n output += '1'\n elif el == '-1':\n output += '0'\n else:\n output += el\nprint(output)\n", "# coding:utf-8\n\nN, M = map(int, input().split(' '))\nans = ['-1' for _ in range(N)]\nif M == 0:\n if N == 1:\n print('0')\n elif N == 2:\n print('10')\n else:\n print('100')\nelse:\n ans = ['-1' for _ in range(N)]\n for _ in range(M):\n s, c = input().split(' ')\n try:\n if ans[int(s)-1] == '-1':\n ans[int(s)-1] = c\n elif ans[int(s)-1] == c:\n pass\n else:\n print('-1')\n exit(0)\n except IndexError:\n print('-1')\n exit(0)\n\n output = ''\n for el in ans:\n if output == '' and el == '-1':\n output += '1'\n elif el =='-1':\n output += '0'\n else:\n output += el\n if output[0] == '0' and len(output) != 1:\n print('-1')\n else:\n print(output)\n"]
['Wrong Answer', 'Accepted']
['s976465767', 's473260565']
[3064.0, 3064.0]
[17.0, 17.0]
[526, 867]
p02761
u294385082
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["n,m = map(int,input().split())\ns = []\nc = []\nif m == 0:\n if n==1:\n print(0)\n elif n==2:\n print(10)\n else:\n print(100)\nexit()\n\nfor i in range(m):\n S,C = map(int,input().split())\n s.append(S)\n c.append(C)\n \nnum = [1] + [0]*(n-1)\nans = ''\n \nfor i in range(m):\n if n != 1 and s[i] == 1 and c[i] == 0:\n print(-1)\n exit()\n elif n == 1 and s[i] == 1 and c[i] == 0:\n print(-1)\n exit()\nfor i in range(m-1):\n for j in range(i+1,m):\n if s[i] == s[j] and c[i] != c[j]:\n print(-1)\n exit()\n \nfor i in range(m):\n num[s[i]-1] = c[i]\n \nfor i in range(n):\n ans += str(num[i])\n \nprint(ans)", "n,m = map(int,input().split())\ns = []\nc = []\nif m == 0:\n if n==1:\n print(0)\n exit()\n elif n==2:\n print(10)\n exit()\n else:\n print(100)\n exit()\n \n \nfor i in range(m):\n S,C = map(int,input().split())\n s.append(S)\n c.append(C)\n \nnum = [1] + [0]*(n-1)\nans = ''\n \nfor i in range(m):\n if n != 1 and s[i] == 1 and c[i] == 0:\n print(-1)\n exit()\nfor i in range(m-1):\n for j in range(i+1,m):\n if s[i] == s[j] and c[i] != c[j]:\n print(-1)\n exit()\n \nfor i in range(m):\n num[s[i]-1] = c[i]\n \nfor i in range(n):\n ans += str(num[i])\n \nprint(ans)"]
['Wrong Answer', 'Accepted']
['s597051011', 's821085541']
[3064.0, 3064.0]
[17.0, 18.0]
[624, 585]
p02761
u297103202
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['judge = False\ntarget = [-1 for i in range(N)]\nfor i in range(M):\n if sc[i][1] + target[sc[i][0]-1] == sc[i][1]-1 or sc[i][1] + target[sc[i][0]-1] == 2*sc[i][1]:\n target[sc[i][0]-1] = sc[i][1]\n else:\n print(-1)\n judge = True\n break\n\nif judge is False:\n for i in range(N):\n if len(target) == 1:\n if target[0] == -1:\n target[0] = 0\n else:\n if i == 0 and target[i] == -1:\n target[i] = 1\n elif target[i] == -1:\n target[i] = 0\n\n res = 0\n for i in range(N):\n res = res+target[i]*(10**(N-i-1))\n if len(str(res)) != N:\n print(-1)\n else:\n print(res)', 'N,M = map(int,input().split())\nsc = [list(map(int,input().split())) for i in range(M)]\njudge = False\ntarget = [-1 for i in range(N)]\nfor i in range(M):\n if sc[i][1] + target[sc[i][0]-1] == sc[i][1]-1 or sc[i][1] + target[sc[i][0]-1] == 2*sc[i][1]:\n target[sc[i][0]-1] = sc[i][1]\n else:\n print(-1)\n judge = True\n break\n\nif judge is False:\n for i in range(N):\n if len(target) == 1:\n if target[0] == -1:\n target[0] = 0\n else:\n if i == 0 and target[i] == -1:\n target[i] = 1\n elif target[i] == -1:\n target[i] = 0\n\n res = 0\n for i in range(N):\n res = res+target[i]*(10**(N-i-1))\n if len(str(res)) != N:\n print(-1)\n else:\n print(res)\n']
['Runtime Error', 'Accepted']
['s940484028', 's264247608']
[3064.0, 3064.0]
[18.0, 17.0]
[701, 789]
p02761
u301624971
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['SC=[]\nN,M = map(int,input().split())\n\nfor _ in range(M):\n SC.append(list(map(int,input().split())))\n\nans=[[0] for i in range(N)]\nfor value in SC:\n ans[value[0]-1].append(value[1])\nketa=10**(N-1)\nansw=0\nfor a in ans:\n a.pop(0)\n tmp=0\n for i in a:\n if(tmp==0 and keta!=1):\n tmp=i\n elif(tmp > i):\n if(i!=0):\n tmp=i\n answ+=tmp*keta\n keta=keta//10\n\nprint(answ) if(len(str(answ))==N) else print(-1)\n', 'A = []\n\nfor _ in range(3):\n lis=list(map(int,input().split()))\n A.append(lis)\n\nN = int(input())\nans=[]\nfor _ in range(N):\n b=int(input())\n for i in range(3):\n if(b in A[i]):\n ans.append([i+1,A[i].index(b)+1])\n break\ntate=False\nif(ans == []):\n print("No")\nelse:\n counter1=[0,0,0]\n counter2=[0,0,0]\n counter3=0\n for a in ans:\n if(a[0]==1):\n counter1[0]+=1\n elif(a[0] == 2):\n counter1[1]+=1\n elif(a[0] == 3):\n counter1[2]+=1\n\n if(a[1] == 1):\n counter2[0]+=1\n elif(a[1] == 2):\n counter2[1]+=1\n elif(a[1] == 3):\n counter2[2]+=1\n if(a[0] == a[1] or a[0] == 1 and a[1] == 3 or a[1]==1 and a[0]==3):\n counter3+=1\n\n if(3 in counter1 or 3 in counter2 or counter3 >=3):\n print("Yes")\n else:\n print("No")\n', 'import sys\nN,M=map(int,input().split())\nSC={}\nfor i in range(1,N + 1):\n SC[i]=[]\nfor _ in range(M):\n s,c=map(int,input().split())\n SC[s].append(c*10**(N - s))\n\nans=[]\nfor h in SC[1]:\n tmp=h\n if(N == 1):\n ans.append(tmp)\n else:\n for t in SC[2]:\n if(N == 2 and tmp != 0):\n ans.append(tmp + t)\n else:\n for j in SC[3]:\n if(len(str(tmp))!= 0):\n ans.append(tmp + t + j)\n \nif(ans == []):\n print(-1)\nelif(len(str(min(ans))) == N):\n print(min(ans))\nelse:\n print(-1)', '\n\ndef solve(N,M,S,C) -> int:\n dic = {key:[] for key in range(1,N+1)}\n ans = 10**5\n for s,c in zip(S,C):\n if(s in dic.keys()):\n dic[s].append(c)\n else:\n dic[s]=[c]\n if(N != 1):\n for i in range(2,N+1):\n if(dic[i] == []):\n dic[i].append(0)\n # print(dic)\n for n in range(10**N):\n length = len(str(n))\n if(length == N):\n for i in range(1,N+1):\n if((int(str(n)[i-1]) in dic[i])==False):\n # print(str(n)[i - 1],dic[i])\n break\n else:\n print(n)\n ans = min(ans,n)\n\n return ans if(ans != 10**5) else -1\n\n\ndef main():\n N,M = map(int,input().split())\n S = []\n C = []\n for _ in range(M):\n s,c = map(int,input().split())\n S.append(s)\n C.append(c)\n # solve()\n print(solve(N,M,S,C))\nif __name__ == "__main__":\n main()\n\n', '\ndef solve(N,M,S,C) -> int:\n for n in range(10**N):\n length = len(str(n))\n if(length == N):\n n = str(n)\n for s,c in zip(S,C):\n if(int(n[s-1]) != c):\n break\n else:\n return n\n return -1\n\n\ndef main():\n N,M = map(int,input().split())\n S = []\n C = []\n for _ in range(M):\n s,c = map(int,input().split())\n S.append(s)\n C.append(c)\n # solve()\n print(solve(N,M,S,C))\nif __name__ == "__main__":\n main()\n\n']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s049990824', 's305716896', 's717144030', 's766419464', 's427543375']
[3064.0, 3064.0, 3064.0, 3064.0, 3064.0]
[18.0, 18.0, 17.0, 19.0, 18.0]
[465, 895, 598, 953, 538]
p02761
u304974600
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n, m = map(int, input().split())\ns = "0" * n\nflag = 0\n\nfor _ in range(m):\n a, b = map(int, input().split())\n\n if s[a - 1] != \'0\':\n if s[a - 1] != str(b):\n flag = 1\n\n if n > 1 and a == 1:\n flag = 1\n \n s = s[:a-1] + str(b) + s[a:]\n\nif flag == 0:\n if n == 1:\n print(s)\n elif int(s) >= 10 ** (n - 1):\n print(s)\n else:\n print(-1)\nelse:\n print(-1)', 'n, m = map(int, input().split())\ns = ""\n\nif n == 1:\n s = "0"\nelif n == 2:\n s = "10"\nelse:\n s = "100"\n\nflag = 0\nchk = [-1] * n\n\nfor _ in range(m):\n a, b = map(int, input().split())\n\n if s[a - 1] != \'0\':\n if s[a - 1] != str(b):\n flag = 1\n\n if n > 1 and a == 1 and b == 0:\n flag = 1\n\n if chk[a - 1] > -1 and chk[a - 1] != b:\n flag = 1\n\n chk[a - 1] = int(b)\n s = s[:a-1] + str(b) + s[a:]\n\nif flag == 0:\n if n == 1:\n print(s)\n elif int(s) >= 10 ** (n - 1):\n print(s)\n else:\n print(-1)\nelse:\n print(-1)', 'n, m = map(int, input().split())\ns = ""\n\nif n == 1:\n s = "0"\nelif n == 2:\n s = "10"\nelse:\n s = "100"\n\nflag = 0\nchk = [-1] * n\n\nfor _ in range(m):\n a, b = map(int, input().split())\n\n if n > 1 and a == 1 and b == 0:\n flag = 1\n\n if chk[a - 1] > -1 and chk[a - 1] != b:\n flag = 1\n\n chk[a - 1] = int(b)\n s = s[:a-1] + str(b) + s[a:]\n\nif flag == 0:\n if n == 1:\n print(s)\n elif int(s) >= 10 ** (n - 1):\n print(s)\n else:\n print(-1)\nelse:\n print(-1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s102119249', 's526155844', 's057725389']
[3064.0, 3064.0, 3064.0]
[17.0, 18.0, 17.0]
[414, 588, 511]
p02761
u305388378
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['def solution():\n n, m = map(int, input().split())\n cs = [list(map(int, input().split())) for i in range(m)]\n if m == 0:\n if n > 1:\n print("-1")\n else:\n print("0")\n return\n ans = [-1 for i in range(n)]\n for w in cs:\n s = w[0]\n c = w[1]\n if (s == 1) and (c == 0) and (n > 1):\n print(\'-1\')\n return\n if ans[s-1] == -1:\n ans[s-1] = c\n elif ans[s-1] != c:\n print(\'-1\')\n return\n ans = [str(i) if i != -1 else str(0) for i in str(ans)]\n anss = \'\'\n for s in ans:\n anss = anss + s\n print(int(anss))\n\nsolution()\n', 'def solution():\n n, m = map(int, input().split())\n cs = [list(map(int, input().split())) for i in range(m)]\n if m == 0:\n if n > 1:\n print("-1")\n else:\n print("0")\n return\n ans = [-1 for i in range(n)]\n for w in cs:\n s = w[0]\n c = w[0]\n if (s == 1) and (c == 0) and (n > 1):\n print(\'-1\')\n return\n if ans[s-1] == -1:\n ans[s-1] = c\n elif ans[s-1] != c:\n print(\'-1\')\n return\n ans = [str(i) if i != -1 else str(0) for i in ans]\n anss = \'\'\n for s in ans:\n anss = anss + s\n print(int(anss))\n\nsolution()\n', 'def solution():\n n, m = map(int, input().split())\n cs = [list(map(int, input().split())) for i in range(m)]\n if m == 0:\n if n > 1:\n print("-1")\n else:\n print("0")\n return\n ans = [-1 for i in range(n)]\n for w in cs:\n s = w[0]\n c = w[1]\n if (s == 1) and (c == 0) and (n > 1):\n print(\'-1\')\n return\n if ans[s-1] == -1:\n ans[s-1] = c\n elif ans[s-1] != c:\n print(\'-1\')\n return\n ansb = [str(i) if i != -1 else str(0) for i in ans]\n if ansb[0] == \'0\':\n ansb[0] = \'1\'\n for s in ansb:\n anss = anss + s\n print(int(anss))\n\nsolution()\n', "def solution():\n n, m = map(int, input().split())\n if m == 0:\n if n > 1:\n print(10**(n-1))\n else:\n print(0)\n return\n\n ans = [-1 for i in range(n)]\n for _ in range(m):\n s, c = map(int, input().split())\n if ((s == 1) and (c == 0) and (n > 1)) or (ans[s-1] not in [c, -1]):\n print(-1)\n return\n ans[s-1] = c\n ans = [i if i != -1 else 0 for i in ans]\n if (ans[0] == 0) and (len(ans) > 1):\n ans[0] = 1\n print(''.join(map(str, ans)))\n\nsolution()\n"]
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s219384645', 's879988467', 's923097225', 's848299094']
[3064.0, 3064.0, 3064.0, 3064.0]
[17.0, 18.0, 17.0, 18.0]
[668, 663, 696, 553]
p02761
u306950978
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['fla = 0\nans = 0\n\nket , kaz = map(int,input().split())\nnum = [-1 for i in range(ket)]\nfor j in range(kaz):\n s , c = map(int,input().split())\n if num[s-1] == -1:\n num[s-1] = c\n elif num[s-1] != c:\n fla = -1\n break\n\nif fla == 0:\n if num[0] == 0:\n if ket != 1 \n fla = -1\n elif num[0] == -1:\n if ket == 1:\n num[0] = 0\n elif ket != 1:\n num[0] = 1\n\nif fla == 0:\n for i in range(ket-1):\n if num[i+1] == -1:\n num[i+1] = 0\n \nif fla == 0:\n for h in range(ket):\n ans += num[h]*(10**(ket-h-1))\n print(ans)\nelif fla == -1:\n print(-1)\n ', 'fla = 0\nans = 0\n\nket , kaz = map(int,input().split())\nnum = [-1 for i in range(ket)]\nfor j in range(kaz):\n s , c = map(int,input().split())\n if num[s-1] == -1:\n num[s-1] = c\n elif num[s-1] != c:\n fla = -1\n break\n\nif fla == 0:\n if num[0] == 0:\n if ket != 1:\n fla = -1\n elif num[0] == -1:\n if ket == 1:\n num[0] = 0\n elif ket != 1:\n num[0] = 1\n\nif fla == 0:\n for i in range(ket-1):\n if num[i+1] == -1:\n num[i+1] = 0\n \nif fla == 0:\n for h in range(ket):\n ans += num[h]*(10**(ket-h-1))\n print(ans)\nelif fla == -1:\n print(-1)']
['Runtime Error', 'Accepted']
['s268006621', 's716888563']
[2940.0, 3064.0]
[17.0, 17.0]
[663, 658]
p02761
u311379832
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["N, M = map(int, input().split())\nsc = [list(map(int, input().split())) for _ in range(M)]\nchk = [0, 0, 0]\ncnt = [0, 0, 0]\nans = ''\ntmp = []\nans = -1\nsc2 = []\n\nfor i in range(M):\n if cnt[sc[i][0] - 1] == 0:\n chk[sc[i][0] - 1] = sc[i][1]\n cnt[sc[i][0] - 1] += 1\n sc2.append([sc[i][0], sc[i][1]])\n else:\n if chk[sc[i][0] - 1] != sc[i][1]:\n print(-1)\n exit()\n\nfor i in range(0, 1000):\n cnt = 0\n for j in range(len(sc2)):\n if len(str(i)) < N:\n break\n if str(i)[sc2[j][0] - 1] == str(sc2[j][1]):\n cnt += 1\n\n if cnt >= len(sc2):\n ans = i\n break\n\nprint(0)", "N, M = map(int, input().split())\nsc = [list(map(int, input().split())) for _ in range(M)]\nchk = [0, 0, 0]\ncnt = [0, 0, 0]\nans = ''\ntmp = []\nans = -1\nsc2 = []\n\nfor i in range(M):\n if cnt[sc[i][0] - 1] == 0:\n chk[sc[i][0] - 1] = sc[i][1]\n cnt[sc[i][0] - 1] += 1\n sc2.append([sc[i][0], sc[i][1]])\n else:\n if chk[sc[i][0] - 1] != sc[i][1]:\n print(-1)\n exit()\n\nfor i in range(0, 1000):\n cnt = 0\n for j in range(len(sc2)):\n if len(str(i)) < N:\n break\n if str(i)[sc2[j][0] - 1] == str(sc2[j][1]):\n cnt += 1\n\n if cnt >= len(sc2):\n ans = i\n break\n\nprint(-1)", 'N, M = map(int, input().split())\nstart = 0\nif N == 1:\n start = 0\nelif N == 2:\n start = 10\nelse:\n start = 100\nN = str(N)\n\nsc = [list(input().split()) for _ in range(M)]\n\nfor i in range(start, 1000):\n ansF = True\n for j in range(M):\n if str(i)[int(sc[j][0]) - 1] != sc[j][1]:\n ansF = False\n break\n if ansF:\n print(i)\n exit()\n\nprint(-1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s605812234', 's945473268', 's097005698']
[3064.0, 3064.0, 3064.0]
[19.0, 19.0, 19.0]
[662, 663, 394]
p02761
u311636831
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N,M = map(int,input().split())\n\nLIST=[10]*N\nfor i in range(M):\n s,c = map(int,input().split())\n if LIST[s-1]==10:\n LIST[s-1]=c\n else:\n print(-1)\n exit()\n\nfor i in range(N):\n if LIST[i]==10:\n LIST[i]=0\n\nLIST2 = map(str, LIST) \nif N==1:\n print("".join(LIST2))\nelif LIST[0]==0:\n print(-1)\nelse:\n print("".join(LIST2))\n\n\n', 'N,M = map(int,input().split())\n\nLIST=[10]*N\nfor i in range(M):\n s,c = map(int,input().split())\n if LIST[N-s] > c:\n LIST[N-s]=c\nfor i in range(N):\n if LIST[i]==10:\n LIST[i]=0\n\nif LIST[0]==0:\n print(-1)\nelse:\n LIST2 = map(str, LIST) \n print("".join(LIST2))\n\n\n', 'N,M = map(int,input().split())\n\nLIST=[[0,0] for i in range(M)]\nfor i in range(M):\n LIST[i][0],LIST[i][1] = map(int,input().split())\nm=1000\nfor i in range(999,-1,-1):\n NUM=str(i)\n if len(NUM)!=N:\n continue\n f=0\n for k in range(M):\n if int(NUM[LIST[k][0]-1])!=LIST[k][1]:\n f=1\n if f == 0:\n m=i\nif m==1000:\n print(-1)\nelse:\n print(m)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s276098900', 's323460124', 's251206351']
[3064.0, 3064.0, 3064.0]
[17.0, 18.0, 19.0]
[366, 289, 386]
p02761
u312158169
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n, m = map(int, input().split())\n\ns = [0] * m\nc = [0] * m\nfor i in range(m):\n s[i], c[i] = map(int, input().split())\n\nnum = 0\nt = 0\n\nif s == 1:\n for i in range(m-1):\n if c[i] != c[i+1]:\n print(-1)\n break\n print(c[0])\nelse:\n if len(set(s)) != len(s):\n for i in range(m):\n for j in range(m):\n if s[i] == s[j] and c[i] != c[j] and i !=j:\n #print(-1)\n t = 1\n break\n\n m = len(set(s))\n s = list(set(s))\n c = list(set(c))\n\n for i in range(m):\n \n num += 10**(n-s[i])*c[i]\n if t == 0 and num >= 10**(n-1)-1:\n \n \tprint(num)\n else :\n print(-1)', 'n, m = map(int, input().split())\n\ns = [0] * m\nc = [0] * m\nfor i in range(m):\n s[i], c[i] = map(int, input().split())\n\nnum = 0\nt = 0\n\n\n\nif s == 1:\n for i in range(m-1):\n if c[i] != c[i+1]:\n print(-1)\n break\n print(c[0])\nelse:\n if len(set(s)) != len(s):\n if len(set(s)) != len(set(c)):\n t = 1\n else:\n for i in range(m):\n for j in range(m):\n if s[i] == s[j] and c[i] != c[j] and i !=j:\n #print(-1)\n t = 1\n break\n\n m = len(set(s))\n s = list(set(s))\n c = list(set(c))\n\n for i in range(m):\n \n num += 10**(n-s[i])*c[i]\n if t == 0 and num >= 10**(n-1)-1 and m != 0:\n \n \tprint(num)\n else :\n print(-1)', 'n, m = map(int, input().split())\n\ns = [0] * m\nc = [0] * m\nfor i in range(m):\n s[i], c[i] = map(int, input().split())\n\nnum = 0\nt = 0\n\nif s == 1:\n for i in range(m-1):\n if c[i] != c[i+1]:\n print(-1)\n break\n print(c[0])\nelse:\n if len(set(s)) != len(s):\n for i in range(m-1):\n if s[i] == s[i+1] and c[i] != c[i+1]:\n #print(-1)\n t = 1\n break\n\n m = len(set(s))\n s = list(set(s))\n c = list(set(c))\n\n for i in range(m):\n \n num += 10**(n-s[i])*c[i]\n if t == 0 and num >= 10**(n-1)-1:\n \n \tprint(num)\n else :\n print(-1)', 'n, m = map(int, input().split())\n\ns = [0] * m\nc = [0] * m\nfor i in range(m):\n s[i], c[i] = map(int, input().split())\n\nnum = 0\nt = 0\ns2 = [0]*n\nif n>1:\n\ts2[0] = 1\n\nif s == 1:\n for i in range(m):\n for j in range(m):\n if c[i] != c[j] :\n print(-1)\n break\n print(c[0])\n \n \nelse:\n if len(set(s)) != len(s):\n \n for i in range(m):\n for j in range(m):\n if s[i] == s[j] and c[i] != c[j] and i !=j:\n #print(-1)\n t = 1\n break\n \n for i in range(m):\n s2[s[i]-1] = c[i]\n \n \n for i in range(n):\n \n \n num += 10**(n-(i+1))*s2[i]\n \n if t == 0 and num >= 10**(n-1)-1 :\n \n \tprint(num)\n else :\n print(-1)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s050791638', 's303390447', 's887506166', 's454846773']
[3444.0, 3444.0, 3064.0, 3064.0]
[21.0, 21.0, 17.0, 17.0]
[706, 782, 673, 791]
p02761
u312666261
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n,m = map(int,input().split())\nketa = []\nnumber = []\n\nfor i in range(m):\n n,a=input().split()\n keta.append(int(n))\n number.append(a)\n\nccount = 0\ncount = 0 \nans = 0\nif n == 3:\n ans = 100\nif n == 2:\n ans = 10\nif n == 1:\n ans = 0\n\nwhile count == 0:\n ans = str(ans)\n for i in range(0,m):\n if ans[keta[i]-1] == number[i]:\n ccount += 1\n if ccount == m:\n count += 1\n ccount = 0\n ans = int(ans)\n ans += 1\n if n = 3 and (ans - 1) == 1000:\n ans = 0\n break\n if n = 2 and (ans - 1) == 100:\n ans = 0\n break\n if n = 1 and (ans - 1) == 10:\n ans = 0\n break\nprint(ans - 1)', 'n,m = map(int,input().split())\nketa = []\nnumber = []\n\nfor i in range(m):\n n,a=input().split()\n keta.append(int(n))\n number.append(a)\n\nccount = 0\ncount = 0 \nans = 0\nif n == 3:\n ans = 100\nif n == 2:\n ans = 10\nif n == 1:\n ans = 0\n\nwhile count == 0:\n ans = str(ans)\n for i in range(0,m):\n if ans[keta[i]-1] == number[i]:\n ccount += 1\n if ccount == m:\n count += 1\n ccount = 0\n ans = int(ans)\n ans += 1\n if n ==3 and (ans - 1) == 1000:\n ans = 0\n break\n if n == 2 and (ans - 1) == 100:\n ans = 0\n break\n if n == 1 and (ans - 1) == 10:\n ans = 0\n break\nprint(ans - 1)', 'n,m = map(int,input().split())\nketa = []\nnumber = []\n\nfor i in range(m):\n b,a=input().split()\n keta.append(int(b))\n number.append(a)\n\nccount = 0\ncount = 0 \nans = 0\nif n == 3:\n ans = 100\nelse:\n pass\nif n == 2:\n ans = 10\nelse:\n pass\nif n == 1:\n ans = 0\nelse:\n pass\n\nwhile count == 0:\n ans = str(ans)\n for i in range(0,m):\n if ans[keta[i]-1] == number[i]:\n ccount += 1\n if ccount == m:\n count += 1\n ccount = 0\n ans = int(ans)\n ans += 1\n if n == 3 and (ans - 1) == 1000:\n ans = 0\n break\n if n == 2 and (ans - 1) == 100:\n ans = 0\n break\n if n == 1 and (ans - 1) == 10:\n ans = 0\n break\nprint(ans - 1)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s652143434', 's801786049', 's561381735']
[3064.0, 3188.0, 3064.0]
[17.0, 2103.0, 19.0]
[638, 640, 683]
p02761
u314050667
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["import sys\n\nN, M = map(int, input().split())\ns,c = [],[]\nfor _ in range(M):\n\tts,tc = map(int ,input().split())\n\ts.append(ts)\n\tc.append(tc)\n\ncond = 0\nflg = [0] * N\nans = ['a'] * N\nfor i in range(M):\n\tif flg[s[i]-1] == 1:\n\t\tcond = 1\n\t\tbreak\n\telse:\n\t\tans[s[i]-1] = str(c[i])\n\t\tflg[s[i]-1] = 1\n\nif ans[0] == '0':\n\tcond = 1\n\nif cond:\n\tprint(-1)\n\tsys.exit()\n\nfor i in range(N):\n\tif i == 0:\n\t\tif ans[i] == 'a':\n\t\t\tans[i] = '1'\n\telse:\n\t\tif ans[i] == 'a':\n\t\t\tans[i] = '0'\n\nprint(''.join(ans))", "import itertools\n\nN, M = map(int, input().split())\ns, c = [], []\nfor _ in range(M):\n\tts,tc = map(int ,input().split())\n\ts.append(ts)\n\tc.append(tc)\n\nans = 10**10\nfor p in itertools.product(range(10), repeat=N):\n\tif N >= 2 and p[0] == 0:\n\t\tcontinue\n\n\n\tcond = 0\n\tfor i in range(M):\n\t\tind = s[i]-1\n\t\tnum = c[i]\n\n\t\tif p[ind] != num:\n\t\t\tcond = 1\n\t\t\tbreak\n\n\tif cond:\n\t\tcontinue\n\telse:\n\t\tans = min(ans, int(''.join(list(map(str, p)))))\n\nif ans == 10**10:\n\tprint(-1)\nelse:\n\tprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s296755294', 's070270763']
[3064.0, 3444.0]
[17.0, 22.0]
[483, 476]
p02761
u316733945
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n, m = map(int, input().split())\nl = [0]*n\n\nfor _ in range(m):\n a, s = map(int, input().split())\n s = str(s)\n if (l[a-1] and l[a-1] != s) or (a==1 and s=="0"):\n l = -1\n break\n else:\n l[a-1] = s\n\nif l == -1:\n print(l)\nelse:\n print("".join(l))', 'n, m = map(int, input().split())\nl = [0]*n\n\nfor _ in range(m):\n a, s = map(int, input().split())\n s = str(s)\n if n == 1 and (a==1 and s=="0"):\n l[0] = s\n elif (l[a-1] and l[a-1] != s) or (a==1 and s=="0"):\n l = [-1]\n break\n else:\n l[a-1] = s\n\nnum = "".join(map(str, l))\n\nif num[0] == "0" and n != 1:\n print("1" + num[1:])\nelse:\n print(num)']
['Runtime Error', 'Accepted']
['s453251083', 's009528040']
[3064.0, 3064.0]
[17.0, 17.0]
[280, 388]
p02761
u317779196
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["n,m = map(int,input().split())\nif n > 1:\n ns = list('1' + '0'*(n-1))\nelse:\n ns = list('0')\n\nss, cc = -1, -1\nfor i in range(m):\n s, c = map(int, input().split())\n if s == ss and c != cc:\n x = False\n break\n ns[s-1] = str(c)\n ss, cc = s, c\n \nif (len(ns) > 1 and ns[0] == '0') or x == False:\n ans = -1\nelse:\n ans = ''.join(ns)\nprint(ans)", "n,m = map(int,input().split())\nif n > 1:\n ns = list('1' + '0'*(n-1))\nelse:\n ns = list('0')\n\nss, cc = -1, -1\nfor i in range(m):\n s, c = map(int, input().split())\n if s == ss and c != cc:\n ns[0] = '-1'\n break\n ns[s-1] = str(c)\n ss, cc = s, c\n \nif (len(ns) > 1 and ns[0] == '0') or ns[0] == '-1':\n ans = -1\nelse:\n ans = ''.join(ns)\nprint(ans)"]
['Runtime Error', 'Accepted']
['s255200952', 's662332052']
[3064.0, 3064.0]
[18.0, 17.0]
[374, 380]
p02761
u318296597
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["from collections import Counter\nN,M = map(int,input().split())\ns = [0 for x in range(M)]\nc = [0 for x in range(M)]\nfor i in range(M) :\n s[i],c[i] = map(int,input().split())\n\nMatrix = [[0,0] for x in range(M)]\nfor i in range(M) : \n Matrix[i][0] = s[i]\n Matrix[i][1] = c[i]\n\nte = Counter(s)\nchofuku = [i[0] for i in te.items() if i[1] >= 2]\nflag = True\n\nfor i in range(len(chofuku)) :\n list_buf = []\n for j in range(M) :\n if Matrix[j][0] == chofuku[i] :\n list_buf.append(Matrix[j][1])\n \n\n if len(set(list_buf)) >= 2 :\n flag = False \n print(-1)\n break\n\nbuf_list = ['' for x in range(N)]\nbuf = 0\nif flag == True :\n list = [0 for x in range(N)]\n for i in range(M) :\n list[s[i]-1] = c[i]\n #print(list)\n if list[0] == 0 :\n print(-1)\n else :\n print(list)\n for i in range(len(list)) :\n buf += list[i] * (10**(len(list)-(i+1)))\n print(buf)", 'N, M = map(int, input().split())\nsc = [tuple(map(int, input().split())) for i in range(M)]\n\nfor i in range(10**N):\n n = str(i)\n if len(n) != N: continue\n if all([n[s-1] == str(c) for s, c in sc]):\n print(n)\n break\nelse:\n print(-1)\n']
['Wrong Answer', 'Accepted']
['s650107666', 's903081584']
[3316.0, 3060.0]
[21.0, 19.0]
[982, 241]
p02761
u318859025
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n,m=map(int,input().split())\nsc=[list(map(int,input().split())) for i in range(m)]\n\nfor i in range(10**n):\n i2=str(i)\n if len(i2)==n and all([i2[s-1]==str(c) for s,c in sc]):\n print(i2)\n break\nprint(-1)', 'n,m=map(int,input().split())\nsc=[list(map(int,input().split())) for i in range(m)]\n\nfor i in range(10**n):\n i2=str(i)\n if len(i2)==n and all([i2[s-1]==str(c) for s,c in sc]):\n print(i2)\n exit()\nprint(-1)']
['Wrong Answer', 'Accepted']
['s663279150', 's110496888']
[3060.0, 3060.0]
[19.0, 18.0]
[214, 215]
p02761
u324197506
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['\nN,M = map(int, input().split())\n\na_list = [0] * N\n\nuncorrect = 0\nchangezero = True\n\nfor i in range(M):\n s,c = map(int, input().split())\n if s == 1:\n zero == False \n if a_list[s-1] == 0:\n a_list[s-1] += c\n else:\n if a_list[s-1] != c:\n uncorrect += 1\n\nif changezero and N >= 2:\n a_list[0] += 1\n\nif uncorrect >= 1:\n print(-1)\nelif a_list[0] == 0 and N >= 2:\n print(-1)\nelse:\n ans = 0\n for i in range(N):\n ans += a_list[i] * (10 ** (N-i-1))\n\n print(ans)', '\nN,M = map(int, input().split())\n\na_list = [0] * N\na_list[0] = -1\n\nuncorrect = 0\n\nfor i in range(M):\n s,c = map(int, input().split())\n if a_list[s-1] == 0:\n a_list[s-1] += c\n else:\n if a_list[s-1] != c:\n uncorrect += 1\n\nif a_list[0] == -1:\n a_list[0] += 2\n\nif uncorrect >= 1:\n print(-1)\nelif a_list[0] == 0 and N >= 2:\n print(-1)\nelse:\n ans = 0\n for i in range(N):\n ans += a_list[i] * (10 ** (N-i-1))\n\n print(ans)', '\nN,M = map(int, input().split())\n\na_list = [0] * N\n\nuncorrect = 0\nchangezero = True\n\nfor i in range(M):\n s,c = map(int, input().split())\n if s == 1:\n changezero = False \n if a_list[s-1] == 0:\n a_list[s-1] += c\n else:\n if a_list[s-1] != c:\n uncorrect += 1\n\nif changezero and N >= 2:\n a_list[0] += 1\n\nif uncorrect >= 1:\n print(-1)\nelif a_list[0] == 0 and N >= 2:\n print(-1)\nelse:\n ans = 0\n for i in range(N):\n ans += a_list[i] * (10 ** (N-i-1))\n\n print(ans)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s088237945', 's278658159', 's451545753']
[3188.0, 3064.0, 3064.0]
[18.0, 17.0, 17.0]
[519, 472, 524]
p02761
u326775883
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["n, m = [int(i) for i in input().split()]\n\nnum = ['0']*n\nl = [0]*n\nb = 0\nfor i in range(m):\n s, c = input().split()\n s = int(s)-1\n if l[s] == 0 or num[s] == c:\n num[s] = c\n l[s] = 1\n else:\n b += 1\n break\n\nif l[0] == 0 and n != 1:\n num[0] = '1'\nelse:\n b += 1\n \n\nif num[0] != '0' and b == 0:\n num = ''.join(num)\n print(int(num))\nelse:\n print(-1)\n", "n, m = [int(i) for i in input().split()]\n\nnum = ['0']*n\nl = [0]*n\nb = 0\nfor i in range(m):\n s, c = input().split()\n s = int(s)-1\n if l[s] == 0 or num[s] == c:\n num[s] = c\n l[s] = 1\n else:\n b += 1\n break\n\nif n >= 2 and l[0] == 1 and num[0] == '0':\n b += 1\nelif n >= 2 and l[0] == 0 and num[0] == '0':\n num[0] = '1'\n\nif b == 0:\n num = ''.join(num)\n print(int(num))\nelse:\n print(-1)\n"]
['Wrong Answer', 'Accepted']
['s385134012', 's154776489']
[3064.0, 3064.0]
[17.0, 17.0]
[367, 401]
p02761
u327532412
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["N, M = map(int, input().split())\nSC = set([tuple(map(int, input().split())) for _ in range(M)])\nchk = {}\nfor s, c in SC:\n if s in chk:\n print(-1)\n exit()\n else:\n chk[s] == 0\nans = [-1] * N\nfor s, c in SC:\n if ans[s-1] == -1:\n ans[s-1] = c\nif N >= 2:\n if ans[0] == -1 or ans[0] == 0:\n print(-1)\n exit()\nkotae = ''\nfor a in ans:\n if a == -1:\n kotae += '0'\n else:\n kotae += str(a)\nprint(kotae)", 'N, M = map(int, input().split())\nSC = set(tuple(map(int, input().split())) for _ in range(M))\n\nfor i in range(10**N):\n num = str(i)\n if len(num) != N:\n continue\n chk = True\n for s, c in SC:\n print(s, c, num)\n if num[s-1] != str(c):\n chk = False\n if chk == True:\n print(num)\n exit()\nprint(-1)', 'N, M = map(int, input().split())\nSC = set(tuple(map(int, input().split())) for _ in range(M))\n\nfor i in range(10**N):\n num = str(i)\n if len(num) != N:\n continue\n chk = []\n for s, c in SC:\n if num[s-1] == str(c):\n chk.append(True)\n else:\n chk.append(False)\n if all(chk):\n print(num)\n exit()\nprint(-1)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s058391979', 's129259584', 's078089277']
[3188.0, 3572.0, 3064.0]
[19.0, 21.0, 18.0]
[464, 352, 371]
p02761
u328755070
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N, M = list(map(int, input().split()))\nsc = []\nfor i in range(M):\n sc.append(list(map(int, input().split())))\n \nnum = "a" * N\n\nfor i in range(M):\n if num[sc[i][0]-1] == "a":\n num = num[:sc[i][0]-1] + str(sc[i][1]) + num[sc[i][0]:]\n else:\n if num[sc[i][0]-1] == str(sc[i][1]):\n continue\n else:\n print(-1)\n break\n\n \nelse:\n if num[0] == "0":\n print(-1)\n else:\n num.replace("a", "0")\n \n print(num)\n ', 'N, M = list(map(int, input().split()))\nsc = []\nfor i in range(M):\n sc.append(list(map(int, input().split())))\n \nfor i in range(1000):\n if len(str(i)) == N:\n for j in range(M):\n s = sc[j][0]\n c = sc[j][1]\n if str(i)[s-1] != str(c):\n break\n else:\n print(i)\n break\n \nelse:\n print(-1)\n \n \n ']
['Wrong Answer', 'Accepted']
['s586426563', 's008871358']
[3064.0, 3064.0]
[18.0, 19.0]
[501, 418]
p02761
u329399746
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N,M = [int(i) for i in input().split(" ")]\ncheck_list = []\n\nfor _ in range(M):\n check_list.append([int(i) for i in input().split(" ")])\n\nfor i in range(10 ** (N + 1)):\n i = str(i)\n for j in check_list:\n if i[j[0] - 1] != str(j[1]):\n break\n else:\n continue\n else:\n print(i)\n break\nelse:\n print(-1)', 'N,M = [int(i) for i in input().split(" ")]\ncheck_list = []\n\nfor _ in range(M):\n check_list.append([int(i) for i in input().split(" ")])\n\nfor i in range(10 ** N):\n i = str(i)\n if len(i) != N:\n continue\n\n for j in check_list:\n if i[j[0] - 1] != str(j[1]):\n break\n else:\n continue\n else:\n print(i)\n break\nelse:\n print(-1)']
['Runtime Error', 'Accepted']
['s945495185', 's348219227']
[3064.0, 3064.0]
[22.0, 18.0]
[361, 393]
p02761
u330169562
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["n, m = map(int, input().split())\nans = []\ntmp = True\nfor i in range(n): ans.append('a')\n\nfor i in range(m):\n s, c = map(int, input().split())\n\n if s == 1 and c == 0:\n tmp = False\n break\n\n if s > n:\n tmp = False\n break\n\n if c < 0 or c > 9:\n tmp = False\n break\n\n if ans[s - 1] == 'a':\n ans[s - 1] = str(c)\n else:\n if ans[s - 1] != str(c):\n tmp = False\n break\n\nif ans[0] == a: ans[0] = '1'\nfor i in range(n):\n if ans[i] == a: ans[i] = '0'\n\nif tmp:\n for i in range(n):\n print(ans[i], end='')\n print()\nelse:\n print('-1')\n\n", "n, m = map(int, input().split())\nans = []\ntmp = True\nfor i in range(n): ans.append('a')\n\nfor i in range(m):\n s, c = map(int, input().split())\n\n if s < 1 or s > n:\n tmp = False\n break\n if c < 0 or c > 9:\n tmp = False\n break\n\n if n != 1 and s == 1 and c == 0:\n tmp = False\n break\n\n if ans[s - 1] == 'a':\n ans[s - 1] = str(c)\n else:\n if ans[s - 1] != str(c):\n tmp = False\n break\n\nif n != 1 and ans[0] == 'a': ans[0] = '1'\nfor i in range(n):\n if ans[i] == 'a': ans[i] = '0'\n\nif tmp:\n for i in range(n):\n print(ans[i], end='')\n print()\nelse:\n print(-1)\n\n"]
['Runtime Error', 'Accepted']
['s785896827', 's643341780']
[3064.0, 3064.0]
[17.0, 18.0]
[632, 664]
p02761
u334175843
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['import bisect,collections,copy,heapq,itertools,math,numpy,string\nimport sys\nsys.setrecursionlimit(10**7)\n\ndef S(): return sys.stdin.readline().rstrip()\ndef I(): return int(sys.stdin.readline().rstrip())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split()))\ndef LS(): return list(sys.stdin.readline().rstrip().split())\n\ndef main():\n N,M = LI()\n SC = [LI() for _ in range(M)]\n a = [0 for _ in range(N)]\n pre = [None for _ in range(N)]\n for s,c in SC:\n s = s-1\n if (a[s]==c) or (pre[s] is None):\n pre[s] = a[s]\n a[s] = c\n else:\n print(-1)\n exit(0)\n ans = int("".join(map(str,a)))\n if len(str(ans))==N:\n for i in range(N):\n if pre[i] is None:\n continue\n else:\n pass\n else:\n print(-1)\n print("{}".format(int(ans)))\n else:\n print(-1)\nmain()\n\n', 'import bisect,collections,copy,heapq,itertools,math,numpy,string\nimport sys\nsys.setrecursionlimit(10**7)\n\ndef S(): return sys.stdin.readline().rstrip()\ndef I(): return int(sys.stdin.readline().rstrip())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split()))\ndef LS(): return list(sys.stdin.readline().rstrip().split())\n\ndef main():\n N,M = LI()\n SC = [LI() for _ in range(M)]\n a = [0 for _ in range(N)]\n pre = [None for _ in range(N)]\n # for s,c in SC:\n \n # if (a[s]==c) or (pre[s] is None):\n # pre[s] = a[s]\n # a[s] = c\n # else:\n # print(-1)\n # exit(0)\n # ans = int("".join(map(str,a)))\n # if len(str(ans))==N:\n # print("{}".format(int(ans)))\n # else:\n # print(-1)\n\n for i in range(1000):\n i = str(i)\n if len(i)==N:\n for s,c in SC:\n if i[s-1] == str(c):\n # print(i[s-1], c)\n continue\n else:\n break\n else:\n print(i)\n exit(0)\n else:\n continue\n else:\n print(-1)\n\nmain()\n\n']
['Wrong Answer', 'Accepted']
['s509284192', 's576765376']
[20816.0, 12432.0]
[311.0, 151.0]
[932, 1179]
p02761
u334365640
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['\nv = []\nm = [False for _ in range(9)]\nfor i in range(3):\n a, b, c = map(int, input().split())\n v += [a, b, c]\n\nn = int(input())\nfor i in range(n):\n a = int(input())\n if a in v:\n m[v.index(a)] = True\n\ndef control():\n for i in range(3):\n if all(m[3*i:3*i+3]):\n return True\n if all(m[i::3]):\n return True\n\n if all(m[::4]) or all(m[2:8:2]):\n return True\n return False\n\nprint("Yes" if control() else "No")', '\n\nn, m = map(int, input().split())\n\ndigits = {i: None for i in range(n)}\ndef main():\n string = ""\n for i in range(m):\n s, c = map(int, input().split())\n if digits[s-1] is not None and digits[s-1] != c:\n return -1\n digits[s-1] = c\n\n if n==1 and m==0:\n return 0\n\n for i, d in digits.items():\n if d is not None:\n if i==0 and d == 0:\n if n==1:\n return 0\n return -1\n string += str(d)\n else:\n if i==0:\n string+= "1"\n else:\n string += "0"\n return int(string)\n\nprint(main())\n\n']
['Runtime Error', 'Accepted']
['s026096994', 's183081699']
[3064.0, 3064.0]
[17.0, 17.0]
[471, 659]
p02761
u334617936
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['import numpy as np\nimport sys\n\ndef main():\n rule = {1:[0, 10], 2:[10, 100], 3:[100, 1000]}\n args = input().rstrip().split(\' \')\n N, M = int(args[0]), int(args[1])\n query = []\n for i in range(M):\n args = input().rstrip().split(\' \')\n query.append([int(args[0]), int(args[1])])\n \n for i in range(rule[N][0], rule[N][1]):\n if(N==1):\n val = np.array([i, -1,-1, -1, -1])\n elif(N==2):\n val = np.array([int(i/10), i%10, -1, -1, -1])\n else:\n val = np.array([int(i/100), int(i%100/10), i%10, -1, -1])\n \n flag = True\n for q in query:\n if(val[q[0]] != q[1]):\n flag = False\n break\n if(flag == True):\n print(i)\n sys.exit(1)\n print(\'-1\')\n \nif __name__ == "__main__":\n main()', 'import numpy as np\n\ndef main():\n rule = {1:[0, 10], 2:[10, 100], 3:[100, 1000]}\n args = input().rstrip().split(\' \')\n N, M = int(args[0]), int(args[1])\n query = []\n for i in range(M):\n args = input().rstrip().split(\' \')\n query.append([int(args[0]), int(args[1])])\n \n global_flag = False\n for i in range(rule[N][0], rule[N][1]):\n if(N==1):\n val = np.array([i, -1,-1, -1, -1])\n elif(N==2):\n val = np.array([int(i/10), i%10, -1, -1, -1])\n else:\n val = np.array([int(i/100), int(i%100/10), i%10, -1, -1])\n \n flag = True\n for q in query:\n if(val[q[0]-1] != q[1]):\n flag = False\n break\n if(flag == True):\n print(i)\n global_flag = True\n break\n if(global_flag == False):\n print(\'-1\')\n \nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s947894299', 's137942716']
[12508.0, 12496.0]
[152.0, 155.0]
[851, 925]
p02761
u334928930
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['def input_int_list():\n return [int(thing) for thing in input().split(" ")]\n\ndef No():\n print(-1)\n exit()\n\n\nN,M=input_int_list()\ns_c_tuple_list=[input_int_list() for i in range(M)]\nthe_dict={}\nfor tup in s_c_tuple_list:\n s,c=tup\n if s==1 and c==0:\n No()\n if s in the_dict:\n if the_dict[s]==c:\n pass\n else:\n No()\n else:\n the_dict[s]=c\n\nprint(int("".join([str(the_dict[i+1]) if i+1 in the_dict else str(1) for i in range(N)])))\n', 'import time\ndef input_int_list():\n return [int(thing) for thing in input().split(" ")]\n\ndef No():\n print(-1)\n exit()\n\n\nN,M=input_int_list()\ns_c_tuple_list=[input_int_list() for i in range(M)]\nthe_dict={}\nfor tup in s_c_tuple_list:\n s,c=tup\n if s==1 and c==0:\n if N==1:\n pass\n else:\n No()\n if s in the_dict:\n if the_dict[s]==c:\n pass\n else:\n No()\n else:\n the_dict[s]=c\n\nif 1 not in the_dict:\n if N==1:\n the_dict[1]=0\n else:\n the_dict[1]=1\ntime.sleep(2)\nthe_num=int("".join([str(the_dict[i+1]) if i+1 in the_dict else str(0) for i in range(N)]))\n\nprint(the_num)\n', 'def input_int_list():\n return [int(thing) for thing in input().split(" ")]\n\ndef No():\n print(-1)\n exit()\n\n\nN,M=input_int_list()\ns_c_tuple_list=[input_int_list() for i in range(M)]\nthe_dict={}\nfor tup in s_c_tuple_list:\n s,c=tup\n if s==1 and c==0:\n No()\n if s in the_dict:\n if the_dict[s]==c:\n pass\n else:\n No()\n else:\n the_dict[s]=c\n\nif 1 not in the_dict:\n if N==1:\n the_dict[1]=0\n else:\n the_dict[1]=1\n\nthe_num=int("".join([str(the_dict[i+1]) if i+1 in the_dict else str(0) for i in range(N)]))\n\n', 'import time\ndef input_int_list():\n return [int(thing) for thing in input().split(" ")]\n\ndef No():\n print(-1)\n exit()\n\n\nN,M=input_int_list()\ns_c_tuple_list=[input_int_list() for i in range(M)]\nthe_dict={}\nfor tup in s_c_tuple_list:\n s,c=tup\n if s==1 and c==0:\n No()\n if s in the_dict:\n if the_dict[s]==c:\n pass\n else:\n No()\n else:\n the_dict[s]=c\n\nif 1 not in the_dict:\n if N==1:\n the_dict[1]=0\n else:\n the_dict[1]=1\ntime.sleep(2)\nthe_num=int("".join([str(the_dict[i+1]) if i+1 in the_dict else str(0) for i in range(N)]))\n\nprint(the_num)\n', 'import time\ndef input_int_list():\n return [int(thing) for thing in input().split(" ")]\n\ndef No():\n print(-1)\n exit()\n\n\nN,M=input_int_list()\ns_c_tuple_list=[input_int_list() for i in range(M)]\nthe_dict={}\nfor tup in s_c_tuple_list:\n s,c=tup\n if s==1 and c==0:\n if N==1:\n pass\n else:\n No()\n if s in the_dict:\n if the_dict[s]==c:\n pass\n else:\n No()\n else:\n the_dict[s]=c\n\nif 1 not in the_dict:\n if N==1:\n the_dict[1]=0\n else:\n the_dict[1]=1\nthe_num=int("".join([str(the_dict[i+1]) if i+1 in the_dict else str(0) for i in range(N)]))\n\nprint(the_num)\n']
['Wrong Answer', 'Time Limit Exceeded', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s123286445', 's412082394', 's584012271', 's814038480', 's627572616']
[3064.0, 3064.0, 3064.0, 3064.0, 3064.0]
[17.0, 2022.0, 17.0, 2020.0, 17.0]
[497, 680, 588, 628, 666]
p02761
u339199690
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N, M = map(int, input().split())\ns = []\nc = []\nfor m in range(M):\n si, ci = map(int, input().split())\n s.append(si)\n c.append(ci)\n\ns = 10 ** (N - 1)\nif N == 1:\n s -= 1\n\nfor i in range(s, 10 ** N):\n for m in range(M):\n if str(i)[s[m] - 1] != str(c[m]):\n break\n else:\n print(i)\n exit()\n\nprint(-1)\n', 'N, M = map(int, input().split())\ns = []\nc = []\nfor m in range(M):\n si, ci = map(int, input().split())\n s.append(si)\n c.append(ci)\n\nss = 10 ** (N - 1)\nif N == 1:\n ss -= 1\n\nfor i in range(ss, 10 ** N):\n for m in range(M):\n if str(i)[s[m] - 1] != str(c[m]):\n break\n else:\n print(i)\n exit()\n\nprint(-1)\n']
['Runtime Error', 'Accepted']
['s918165300', 's915424344']
[3064.0, 3064.0]
[18.0, 18.0]
[345, 348]
p02761
u343977188
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N, M = map(int, input().split())\nX = [-1] * N#[-1,-1,-1.....]\nfor i in range(M):\n s, c = map(str, input().split())\n if s == 1 and N > 1 and c==0:\n print(-1)\n exit()\n if X[s-1] < 0:\n X[s-1] = c\n \n \n elif X[s-1] != c:\n print(-1)\n exit()\n\n\nif X[0] < 0 :\n X[0] = 1 if N>1 else 0\nprint("".join([str(x) if x >= 0 else "0" for x in X]))\n', 'N, M = map(int, input().split())\nX = [-1] * N#[-1,-1,-1.....]\nfor _ in range(M):\n s, c = map(int, input().split())\n if s == 1 and N > 1 and c==0:\n print(-1)\n exit()\n\n\n if X[s-1] < 0:\n X[s-1] = c\n \n\n elif X[s-1] != c:\n print(-1)\n exit()\n\n\nif X[0] < 0 :\n X[0] = 1 if N>1 else 0\nprint("".join([str(x) if x >= 0 else "0" for x in X]))\n']
['Runtime Error', 'Accepted']
['s658432540', 's768737864']
[3064.0, 3064.0]
[18.0, 17.0]
[866, 864]
p02761
u344813796
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n,m=map(int,input().split())\nSC=[list(map(int,input().split())) for _ in range(m)]\n\nfor i in range(10*n):\n num=str(i)\n if len(num)==n and all(num[s-1]==str(c) for s,c in SC):\n print(i)\n break\nelse:\n print(-1)\n', 'n,m=map(int,input().split())\nSC=[list(map(int,input().split())) for _ in range(m)]\nans=[0 for _ in range(n)]\nansh=[0 for _ in range(n)]\nfor sc in SC:\n if ansh[sc[0]-1]==0:\n ans[sc[0]-1]=sc[1]\n ansh[sc[0]-1]=1\n else:\n print(-1)\n exit()\nif ans[0]!=0:\n print(*ans,sep="")\nelse:\n print(-1)', 'n,m=map(int,input().split())\nSC=[list(map(int,input().split())) for _ in range(m)]\n\nfor i in range(10**n):\n if len(str(i))==n and all(str(i)[s-1]==str(c) for s,c in SC):\n print(i)\n break\nelse:\n print(-1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s034769539', 's343473836', 's804373609']
[9160.0, 9060.0, 9028.0]
[26.0, 27.0, 26.0]
[232, 325, 223]
p02761
u346308892
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['\nimport numpy as np\nfrom functools import *\nimport sys\nsys.setrecursionlimit(100000)\n\n\n\ndef acinput():\n return list(map(int, input().split(" ")))\n\n\ndef II():\n return int(input())\n\ndirections=np.array([[1,0],[0,1],[-1,0],[0,-1]])\ndirections = list(map(np.array, directions))\n\nmod = 10**9+7\n\n\ndef factorial(n):\n fact = 1\n for integer in range(1, n + 1):\n fact *= integer\n return fact\n\n\n\ndef serch(x, count):\n #print("top", x, count)\n \n\n for d in directions:\n nx = d+x\n #print(nx)\n if np.all(0 <= nx) and np.all(nx < (H, W)):\n if field[nx[0]][nx[1]] == "E":\n count += 1 \n field[nx[0]][nx[1]] = "V"\n count = serch(nx, count) \n continue\n if field[nx[0]][nx[1]] == "#":\n field[nx[0]][nx[1]] = "V"\n count = serch(nx, count) \n \n return count\n\nN,M=acinput()\n\ndigit=[-1]*N\nfor i in range(M):\n s=acinput()\n if digit[s[0]-1] >= 0 and digit[s[0]-1]!=s[1]:\n print(-1)\n sys.exit()\n\n digit[s[0]-1]=s[1]\n\nprint(digit)\nif digit[0]==0:\n print(-1)\n sys.exit()\n\n\nfor i in range(N):\n if digit[i]<0:\n digit[i]=0\n\n\nprint(digit)\n', '\nimport numpy as np\nfrom functools import *\nimport sys\nsys.setrecursionlimit(100000)\n\n\n\ndef acinput():\n return list(map(int, input().split(" ")))\n\n\ndef II():\n return int(input())\n\ndirections=np.array([[1,0],[0,1],[-1,0],[0,-1]])\ndirections = list(map(np.array, directions))\n\nmod = 10**9+7\n\n\ndef factorial(n):\n fact = 1\n for integer in range(1, n + 1):\n fact *= integer\n return fact\n\n\n\ndef serch(x, count):\n #print("top", x, count)\n \n\n for d in directions:\n nx = d+x\n #print(nx)\n if np.all(0 <= nx) and np.all(nx < (H, W)):\n if field[nx[0]][nx[1]] == "E":\n count += 1 \n field[nx[0]][nx[1]] = "V"\n count = serch(nx, count) \n continue\n if field[nx[0]][nx[1]] == "#":\n field[nx[0]][nx[1]] = "V"\n count = serch(nx, count) \n \n return count\n\nN,M=acinput()\n\ndigit=[-1]*N\nfor i in range(M):\n s=acinput()\n if digit[s[0]-1] >= 0 and digit[s[0]-1]!=s[1]:\n print(-1)\n sys.exit()\n\n digit[s[0]-1]=s[1]\n\n\nif digit[0]==0:\n print(-1)\n sys.exit()\n\n\nfor i in range(N):\n if digit[i]<0:\n digit[i]=0\n\n\nprint(" ".join(map(str,digit)))\n', '\nimport numpy as np\nfrom functools import *\nimport sys\nsys.setrecursionlimit(100000)\n\n\n\ndef acinput():\n return list(map(int, input().split(" ")))\n\n\ndef II():\n return int(input())\n\ndirections=np.array([[1,0],[0,1],[-1,0],[0,-1]])\ndirections = list(map(np.array, directions))\n\nmod = 10**9+7\n\n\ndef factorial(n):\n fact = 1\n for integer in range(1, n + 1):\n fact *= integer\n return fact\n\nN,M=acinput()\n\ndigit=[-1]*N\nfor i in range(M):\n s=acinput()\n if digit[s[0]-1] >= 0 and digit[s[0]-1]!=s[1]:\n print(-1)\n sys.exit()\n\n digit[s[0]-1]=s[1]\n\n\n\nif N==1:\n if digit[0] == 0 or digit[0] == -1:\n print(0)\n sys.exit()\n\n\n\n \nif digit[0]==0:\n print(-1)\n sys.exit()\n\nif digit[0]==-1:\n digit[0]=1\n\nfor i in range(1,N):\n if digit[i]<0:\n digit[i]=0\n\n\nprint(int("".join(map(str,digit))))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s039869138', 's776840100', 's462220850']
[12512.0, 12528.0, 12512.0]
[150.0, 154.0, 148.0]
[1238, 1258, 869]
p02761
u347452770
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n , m = map(int, input().split())\nl_1 = [] \nl_2 = [] \nl_3 = [] \nnocounter = 0\nanswer = 100 \n \nif m == 0:\n print(0)\nelse:\n for i in range(m):\n a, b = map(int, input().split())\n if a == 1:\n l_1.append(b)\n elif a == 2:\n l_2.append(b)\n else:\n l_3.append(b)\n pv = l_1[0]\n for j in range(len(l_1)):\n if not pv == l_1[j]:\n nocounter += 1\n if l_1[j] == 0:\n nocounter += 1\n pv = l_2[0]\n for j in range(len(l_2)):\n if not pv == l_2[j]:\n nocounter += 1\n pv = l_3[0]\n for j in range(len(l_3)):\n if not pv == l_3[j]:\n nocounter += 1\n if nocounter > 0:\n print(-1)\n else:\n if n == 1:\n print(l_3[0])\n elif n == 2 and len(l_2)*lemn(l_1) == 1:\n print(10*l_1[0] + l_2[0])\n elif n == 2 and len(l_1) == 0:\n print(10 + l_2[0])\n elif n == 2 and len(l_2) == 0:\n print(10*l_1[0])\n elif len(l_1)*len(l_2)*len(l_3) == 1:\n print(100*l_1[0] + 10*l_2[0] + l_3[0])\n elif len(l_1) == 0:\n print(100 + 10*l_2[0] + l_3[0])\n elif len(l_2) == 0:\n print(100*l_1[0] + l_3[0])\n else:\n print(100*l_1[0] + 10*l_2[0])', 'n , m = map(int, input().split())\nl_1 = [] \nl_2 = [] \nl_3 = [] \nnocounter = 0\nanswer = 100 \n\nif m == 0:\n print(0)\nelse:\n for i in range(m):\n a, b = map(int, input().split())\n if a == 1:\n l_1.append(b)\n elif a == 2:\n l_2.append(b)\n else:\n l_3.append(b)\n pv = l_1[0]\n for j in range(len(l_1)):\n if not pv == l_1[j]:\n nocounter += 1\n if l_1[j] == 0:\n nocounter += 1\n pv = l_2[0]\n for j in range(len(l_2)):\n if not pv == l_2[j]:\n nocounter += 1\n pv = l_3[0]\n for j in range(len(l_3)):\n if not pv == l_3[j]:\n nocounter += 1\n if nocoutner > 0:\n print(-1)\n else:\n if n == 1:\n print(l_3[0])\n elif n == 2 && len(l_2)*lemn(l_1) == 1:\n print(10*l_1[0] + l_2[0])\n elif n == 2 && len(l_1) == 0:\n print(10 + l_2[0])\n elif n == 2 && len(l_2) == 0:\n print(10*l_1[0])\n elif len(l_1)*len(l_2)*len(l_3) == 1:\n print(100*l_1[0] + 10*l_2[0] + l_3[0])\n elif len(l_1) == 0:\n print(100 + 10*l_2[0] + l_3[0])\n elif len(l_2) == 0:\n print(100*l_1[0] + l_3[0])\n else:\n print(100*l_1[0] + 10*l_2[0])\n \n\n\n ', 'n , m = map(int, input().split())\nl_1 = [] \nl_2 = [] \nl_3 = [] \nnocounter = 0\n \nif m == 0:\n if n == 1:\n print(0)\n elif n == 2:\n print(10)\n else:\n print(100)\nelse:\n for i in range(m):\n a, b = map(int, input().split())\n if a == 1:\n l_1.append(b)\n elif a == 2:\n l_2.append(b)\n else:\n l_3.append(b)\n if len(l_1) > 0:\n pv = l_1[0]\n for j in range(len(l_1)):\n if not pv == l_1[j]:\n nocounter += 1\n if l_1[j] == 0 and n > 1:\n nocounter += 1\n if len(l_2) > 0:\n pv = l_2[0]\n for j in range(len(l_2)):\n if not pv == l_2[j]:\n nocounter += 1\n if len(l_3) > 0:\n pv = l_3[0]\n for j in range(len(l_3)):\n if not pv == l_3[j]:\n nocounter += 1\n if nocounter > 0:\n print(-1)\n else:\n if n == 1:\n print(l_1[0])\n elif n == 2 and len(l_2)*len(l_1) > 0:\n print(10*l_1[0] + l_2[0])\n elif n == 2 and len(l_1) == 0:\n print(10 + l_2[0])\n elif n == 2 and len(l_2) == 0:\n print(10*l_1[0])\n elif len(l_1)*len(l_2)*len(l_3) > 0:\n print(100*l_1[0] + 10*l_2[0] + l_3[0])\n elif len(l_1) == 0 and len(l_2) == 0:\n print(100 + l_3[0])\n elif len(l_1) == 0 and len(l_3) == 0:\n print(100 + 10*l_2[0])\n elif len(l_1) == 0:\n print(100 + 10*l_2[0] + l_3[0])\n elif len(l_2) == 0 and len(l_3) == 0:\n print(100*l_1[0])\n elif len(l_2) == 0 :\n print(100*l_1[0] + l_3[0])\n else:\n print(100*l_1[0] + 10*l_2[0])']
['Runtime Error', 'Runtime Error', 'Accepted']
['s304237700', 's750523898', 's012236805']
[3188.0, 3064.0, 3192.0]
[17.0, 17.0, 17.0]
[1229, 1235, 1579]
p02761
u347600233
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["n, m = map(int, input().split())\nans = [-1] * n\nexist = True\nfor i in range(m):\n s, c = map(int, input().split())\n if (n != 1 and (s, c) == (1, 0)) or (ans[s - 1] != -1 and ans[s - 1] != c):\n exist = False\n break\n else:\n ans[s - 1] = c\n\nif exist:\n for i in range(n):\n if n != 1 and i == 0:\n if ans[i] == -1:\n ans[i] = 1\n else:\n if ans[i] == -1:\n ans[i] = 0\n\n print(*ans, sep='')\nelse:\n print(-1)", "n, m = map(int, input().split())\nnumber = ['x' for i in range(n)]\nflag = True\nfor i in range(m):\n s, c = map(int, input().split())\n if n != 1 and s == 1 and c ==0:\n flag = False\n if number[s - 1] != 'x' and number[s - 1] != c:\n flag = False\n number[s - 1] = c\n\nfor i in range(n):\n if number[i] == 'x':\n number[i] = 0\n\nif flag:\n for i in range(n):\n print(number[i], end='')\nelse:\n print(-1)", "n, m = map(int, input().split())\nnumber = ['x' for i in range(n)]\nflag = True\nfor i in range(m):\n s, c = map(int, input().split())\n if n != 1 and s == 1 and c ==0:\n flag = False\n if number[s - 1] != 'x' and number[s - 1] != c:\n flag = False\n number[s - 1] = c\n\nif number[0] == 'x':\n number[0] = 1\nfor i in range(1, n):\n if number[i] == 'x':\n number[i] = 0\n\nif flag:\n for i in range(n):\n print(number[i], end='')\nelse:\n print(-1)", 'n, m = map(int, input().split())\nsc = [tuple(map(int, input().split())) for j in range(m)]\nfor i in range(10**n):\n if len(str(i)) == n and all(str(i)[s - 1] == str(c) for s, c in sc):\n print(i)\n break\nelse:\n print(-1)']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s525864224', 's896867608', 's914600390', 's081409269']
[8992.0, 3064.0, 3064.0, 9132.0]
[28.0, 17.0, 17.0, 28.0]
[476, 439, 481, 237]
p02761
u347640436
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N, M = map(int, input().split())\nsc = [tuple(map(int, input().split())) for _ in range(M)]\n\nfor i in range(1000):\n t = str(i)\n if len(t) != N:\n continue\n ok = True\n for s, c in sc:\n if t[int(s) - 1] != int(c):\n ok = False\n break\n if ok:\n print(i)\n exit()\nprint(-1)\n', 'N, M = map(int, input().split())\nsc = [tuple(map(int, input().split())) for _ in range(M)]\n\nfor i in range(1000):\n t = str(i)\n if t != N:\n continue\n ok = True\n for s, c in sc:\n if t[int(s)] != int(c):\n ok = False\n break\n if ok:\n print(i)\n exit()\nprint(-1)\n', 'N, M = map(int, input().split())\nsc = [tuple(map(int, input().split())) for _ in range(M)]\n\nfor i in range(1000):\n t = str(i)\n if len(t) != N:\n continue\n ok = True\n for s, c in sc:\n if t[int(s)] != int(c):\n ok = False\n break\n if ok:\n print(i)\n exit()\nprint(-1)\n', 'N, M = map(int, input().split())\nsc = [tuple(map(int, input().split())) for _ in range(M)]\n\nfor i in range(1000):\n t = str(i)\n if len(t) != N:\n continue\n ok = True\n for s, c in sc:\n if int(t[s - 1]) != c:\n ok = False\n break\n if ok:\n print(i)\n exit()\nprint(-1)\n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s384706568', 's774042519', 's846588073', 's031708043']
[3060.0, 3316.0, 3316.0, 3060.0]
[18.0, 19.0, 19.0, 17.0]
[330, 321, 326, 325]
p02761
u348868667
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['def main():\n N,M = map(int,input().split())\n sc = [list(map(int,input().split())) for _ in range(M)]\n tmp = [[] for _ in range(N)]\n for i in range(M):\n s,c = sc[i][0],sc[i][1]\n tmp[s-1].append(c)\n ans = []\n for i in range(N):\n if len(set(tmp[i])) >= 2:\n ans = "-1"\n break\n if ans == "-1":\n print(ans)\n else:\n cc = []\n for i in range(1000):\n st = list(str(i))\n for j in range(N):\n if len(tmp[j]) == 0 or len(st) < N:\n continue\n if st[j] != str(tmp[j][0]):\n ans = "-1"\n break\n if j == N-1 and len(st) == N:\n cc.append(i)\n print(cc)[0]\n\n\nif __name__ == \'__main__\':\n main()', 'def main():\n N,M = map(int,input().split())\n sc = [list(map(int,input().split())) for _ in range(M)]\n if M == 0:\n if N != 1:\n print(10**(N-1))\n else:\n print(0)\n else:\n ans = "-1"\n flag = False\n for i in range(10**N):\n if flag:\n break\n tmp = str(i)\n if len(tmp) < N:\n continue\n for j in range(M):\n if tmp[sc[j][0]-1] != str(sc[j][1]):\n break\n if j == M-1:\n ans = i\n flag = True\n print(ans)\n\nif __name__ == \'__main__\':\n main()\n']
['Runtime Error', 'Accepted']
['s150852037', 's200002927']
[3184.0, 3064.0]
[20.0, 18.0]
[810, 665]
p02761
u349888092
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['import sys\nN,M = map(int,input().split())\nans = [0]*N\ndict1 = {}\nfor x in range(M):\n a,b = map(int,input().split())\n if((a in dict1) != True):\n dict1[a] = b\n elif(dict1[a] == b):\n dict1[a] = b\n else:\n print(-1)\n sys.exit()\nfor k, v in dict1.items():\n ans[k-1] = v\nprint(ans)\nl = "".join([str(n) for n in ans])\nint_l = int(l)\nprint(int_l)\nlen_l = len(str(int_l))\nif(N >= 2 and ( 0 in dict1)):\n print(-1)\nelse:\n print(int_l)', 'import sys\nN,M = map(int,input().split())\nans = [0]*N\ndict1 = {}\nfor x in range(M):\n a,b = map(int,input().split())\n if((a in dict1) != True):\n dict1[a] = b\n elif(a in dict1 and dict1[a] != b)):\n print(-1)\n sys.exit()\nfor k, v in dict1.items():\n ans[k-1] = v\n if(k == 1 and v == 0 and N == 3):\n print(-1)\n sys.exit()\n elif(k == 1 and v == 0 and N ==2):\n print(-1)\n sys.exit()\n#print(ans)\nl = "".join([str(n) for n in ans])\nint_l = int(l)\nprint(int_l)\n#len_l = len(str(int_l))\n#print(int_l)', 'import sys\nN,M = map(int,input().split())\nans = [0]*N\ndict1 = {}\nif n > 1:\n ans[0] = 1\nfor x in range(M):\n a,b = map(int,input().split())\n if((a in dict1) != True):\n dict1[a] = b\n elif(a in dict1 and dict1[a] != b):\n print(-1)\n sys.exit()\nfor k, v in dict1.items():\n ans[k-1] = v\n if(k == 1 and v == 0 and N >= 2):\n print(-1)\n sys.exit()\n#print(ans)\nl = "".join([str(n) for n in ans])\nint_l = int(l)\nprint(int_l)\n#len_l = len(str(int_l))\n#print(int_l)', 'import sys\nN,M = map(int,input().split())\nans = [0]*N\ndict1 = {}\nfor x in range(M):\n a,b = map(int,input().split())\n if((a in dict1) != True):\n dict1[a] = b\n elif(a in dict1 and dict1[a] != b)):\n print(-1)\n sys.exit()\nfor k, v in dict1.items():\n ans[k-1] = v\n if(k == 1 and v == 0 and N == 3):\n print(-1)\n sys.exit()\n elif(k == 1 and v == 0 and N ==2):\n print(-1)\n sys.exit()\n#print(ans)\nl = "".join([str(n) for n in ans])\nint_l = int(l)\nprint(int_l)\n#len_l = len(str(int_l))\n#print(int_l)', 'import sys\nN,M = map(int,input().split())\nans = [0]*N\ndict1 = {}\nif N > 1:\n ans[0] = 1\nfor x in range(M):\n a,b = map(int,input().split())\n if((a in dict1) != True):\n dict1[a] = b\n elif(a in dict1 and dict1[a] != b):\n print(-1)\n sys.exit()\nfor k, v in dict1.items():\n ans[k-1] = v\n if(k == 1 and v == 0 and N >= 2):\n print(-1)\n sys.exit()\n#print(ans)\nl = "".join([str(n) for n in ans])\nint_l = int(l)\nprint(int_l)\n#len_l = len(str(int_l))\n#print(int_l)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s077530412', 's238965257', 's629156837', 's808186081', 's959508629']
[3064.0, 2940.0, 3064.0, 2940.0, 3064.0]
[17.0, 18.0, 17.0, 17.0, 17.0]
[471, 556, 505, 556, 505]
p02761
u353652911
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n,m=map(int,input().split())\nans=["x"]*n\n\nfor i in range(m):\n a,b=map(int,input().split())\n \n if ans[a-1]=="x" or ans[a-1]==b:\n ans[a-1]=b\n else:\n print(-1)\n exit()\n\nif n==1 and ans[0]==0:\n print(0)\nelif n>1 and ans[0]==0:\n print(-1)\nelif "x" not in ans:\n print ("".join(ans))\n \nelse:\n for j in range(n):\n if ans[j]=="x":\n ans[j]=0\n print(ans[j], end="")\n \n', 'n,m=map(int,input().split())\nans=[]\n\nfor i in range(m):\n ans.append(list(map(int,input().split())))\nfor j in range(10**n):\n if len(str(j))==n and all(str(j)[s-1]==str(c) for s,c in ans):\n print(j)\n break\nelse:\n print(-1)']
['Runtime Error', 'Accepted']
['s283397112', 's105643094']
[3064.0, 3060.0]
[18.0, 18.0]
[441, 243]
p02761
u353919145
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['#graph implementation\nimport math\nn,m=map(int,input().split())\nans=[0]*n\nfor i in range(m):\n s,c=map(int,input().split())\n if ans[s-1]>=c:\n ans[s-1]=c\nif ans[0]==0:\n print(-1)\nelse:\n for i in ans:\n print(i,end="")\nprint()\n', 'def f():\n n, m = list(map(int, input().split()))\n a = [-1, -1, -1, -1]\n\n for c in range(m):\n x = list(map(int, input().split()))\n if(a[x[0]] == -1):\n a[x[0]] = x[1]\n else:\n if(a[x[0]] != x[1]):\n return -1\n for y in range(4):\n if(a[y] == -1):\n a[y] = 1\n #print(a)\n \n s = 0\n for i in range(1,4):\n s *= 10\n s += a[i]\n \n #print(s)\n if(len(list(str(s))) != n):\n return -1\n return s\n\n \n\n\n\n\nx = f()\nif(x == -1):\n print("-1")\nelse:\n print(x)\n\n', 'n = list(map(int, input().split()))\n\ndef getNum(n, m):\n num = [-1] * n\n for i in range(m):\n digits = list(map(int, input().split()))\n if (digits[0] == 1 and digits[1] == 0 and n != 1) or (num[digits[0] - 1] != -1 and num[digits[0] - 1] != digits[1]):\n return -1\n else:\n num[digits[0] - 1] = digits[1]\n if num[0] == -1 and len(num) == 1:\n num[0] = 0\n elif num[0] == -1:\n num[0] = 1\n number = ""\n for item in num:\n if item == -1:\n item = 0\n number += str(item)\n return number\n\nprint(getNum(n[0], n[1]))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s490831845', 's859596663', 's552028630']
[3060.0, 3064.0, 3064.0]
[17.0, 17.0, 18.0]
[248, 499, 603]
p02761
u355853184
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N, M = map(int, input().split())\n\ns = []\nc = []\nfor i in range(M):\n x,y = map(int,input().split())\n s.append(x)\n c.append(y)\n\nans_list = [0 for i in range(N)]\n\nfor i in range(M):\n if ans_list[s[i]-1] != -1 and ans_list[s[i]-1] != c[i]:\n print(-1)\n exit()\n else:\n ans_list[s[i]-1] = c[i]\n#print(ans_list)\nif ans_list[0] == 0:\n print(-1)\n exit()\n\n\nans = 0\nfor i in range(N):\n if ans_list[i] == 0 and i != 0:\n ans_list[i] = 0\n if ans_list[i] == 0 and i == 0 and N >= 2:\n ans_list[i] = 1\n if ans_list[i] == 0 and i == 0 and N == 1:\n ans_list[i] = 0\n ans += ans_list[i] * (10**(N-i-1))\n\nprint(ans)\n', 'N, M = map(int, input().split())\n\ns = []\nc = []\nfor i in range(M):\n x,y = map(int,input().split())\n s.append(x)\n c.append(y)\n\nans_list = [-1 for i in range(N)]\n\nfor i in range(M):\n if ans_list[s[i]-1] != -1 and ans_list[s[i]-1] != c[i]:\n print(-1)\n exit()\n else:\n ans_list[s[i]-1] = c[i]\n#print(ans_list)\nif ans_list[0] == 0 and N>=2:\n print(-1)\n exit()\n\nans = 0\nfor i in range(N):\n if ans_list[i] == -1 and i != 0:\n ans_list[i] = 0\n if ans_list[i] == -1 and i == 0 and N >= 2:\n ans_list[i] = 1\n if ans_list[i] == -1 and i == 0 and N == 1:\n ans_list[i] = 0\n ans += ans_list[i] * (10**(N-i-1))\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s449009533', 's194592220']
[9248.0, 9252.0]
[31.0, 30.0]
[669, 681]
p02761
u357949405
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N, M = map(int, input().split())\n\nS = []\nC = []\n\ncondition = [-1] * M\n\nfor _ in range(M):\n s, c = map(int, input().split())\n #S.append(s)\n #C.append(C)\n if condition[s-1] != c and condition[s-1] != -1:\n print(\'-1\')\n exit()\n condition[s-1] = c\n\nfor i, v in enumerate(condition):\n if v == -1:\n condition[i] = 0\n print(condition[i], end="")\n', 'N, M = map(int, input().split())\n\nans = [-1] * N\nif N == 1 and M == 0:\n print(0)\n exit(0)\nfor _ in range(M):\n sn, cn = map(int, input().split())\n if ans[sn - 1] != -1 and ans[sn - 1] != cn:\n print(-1)\n exit(0)\n if sn == 1 and cn == 0 and N > 1:\n print(-1)\n exit(0)\n ans[sn - 1] = cn\nif ans[0] == -1:\n ans[0] = 1\nans = list(map(lambda x: str(0) if x == -1 else str(x), ans))\nprint("".join(ans))\n']
['Runtime Error', 'Accepted']
['s174143683', 's714947610']
[3060.0, 3064.0]
[17.0, 17.0]
[380, 443]
p02761
u359619351
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['import sys\nsys.setrecursionlimit(4100000)\n\nimport math\n\nimport logging\n\nlogging.basicConfig(level=logging.DEBUG)\n\nlogger = logging.getLogger(__name__)\n\n\ndef resolve():\n \n \n N, M = [int(x) for x in sys.stdin.readline().split()] \n # h_list = [int(x) for x in sys.stdin.readline().split()] \n\n \n # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]\n grid = [[int(x) for x in sys.stdin.readline().split()]\n for _ in range(M)] \n\n logger.debug(\'{}\'.format([]))\n\n d = dict()\n\n ret = [1 for _ in range(N)]\n\n for s, c in grid:\n if d.get(s, c) != c:\n print(-1)\n return\n\n d[s] = c\n\n ret[s - 1] = c\n\n if len(ret) == 1:\n print(ret[0])\n\n else:\n if ret[0] == 0:\n print(-1)\n else:\n print(\'\'.join([str(t) for t in ret]))\n\n\nif __name__ == "__main__":\n resolve()\n\n\n\n\n\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_入力例_1(self):\n input = """3 3\n1 7\n3 2\n1 7"""\n output = """702"""\n self.assertIO(input, output)\n\n def test_入力例_2(self):\n input = """3 2\n2 1\n2 3"""\n output = """-1"""\n self.assertIO(input, output)\n\n def test_入力例_3(self):\n input = """3 1\n1 0"""\n output = """-1"""\n self.assertIO(input, output)\n', 'import sys\nsys.setrecursionlimit(4100000)\n\nimport math\n\nimport logging\n\nlogging.basicConfig(level=logging.DEBUG)\n\nlogger = logging.getLogger(__name__)\n\n\ndef resolve():\n \n \n N, M = [int(x) for x in sys.stdin.readline().split()] \n # h_list = [int(x) for x in sys.stdin.readline().split()] \n\n \n # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]\n grid = [[int(x) for x in sys.stdin.readline().split()]\n for _ in range(M)] \n\n logger.debug(\'{}\'.format([]))\n\n d = dict()\n\n ret = [0 for _ in range(N)]\n\n for s, c in grid:\n if d.get(s, c) != c:\n print(-1)\n return\n\n d[s] = c\n\n ret[s - 1] = c\n\n if len(ret) == 1:\n print(ret[0])\n\n else:\n if ret[0] == 0:\n if d.get(1, None) == 0:\n print(-1)\n else:\n ret[0] = 1\n print(\'\'.join([str(t) for t in ret]))\n else:\n print(\'\'.join([str(t) for t in ret]))\n\n\nif __name__ == "__main__":\n resolve()\n\n\n\n\n\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_入力例_1(self):\n input = """3 3\n1 7\n3 2\n1 7"""\n output = """702"""\n self.assertIO(input, output)\n\n def test_入力例_2(self):\n input = """3 2\n2 1\n2 3"""\n output = """-1"""\n self.assertIO(input, output)\n\n def test_入力例_3(self):\n input = """3 1\n1 0"""\n output = """-1"""\n self.assertIO(input, output)\n']
['Wrong Answer', 'Accepted']
['s870913993', 's273446431']
[5656.0, 5648.0]
[42.0, 43.0]
[2147, 2286]
p02761
u363074342
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["N, M = map(int,input().split())\nans = -1\nif N == 1:\n kazu = list(range(10))\nelif N == 2:\n kazu = list(range(10,100,1))\nelse:\n kazu = list(range(100,1000,1))\n\n\nneikazu = kazu\n\nfor j in range(M):\n s, c = map(int,input().split())\n print(s,c)\n for i in range(1000):\n if i not in kazu:\n pass\n else:\n if N + 1 - s == 1:\n if i % 10 != c:\n kazu.remove(i)\n #print('KKK')\n elif N + 1 - s == 2:\n if (i % 100) //10 != c:\n kazu.remove(i)\n #print('JJJ')\n else:\n if i // 100 != c:\n kazu.remove(i)\n #print('HHH')\nif len(kazu) == 0:\n pass\nelse:\n ans = kazu[0]\n\n\nprint(ans)\n\n\n \n\n", "N, M = map(int,input().split())\nans = -1\nif N == 1:\n kazu = list(range(10))\nelif N == 2:\n kazu = list(range(10,100,1))\nelse:\n kazu = list(range(100,1000,1))\n\n\nneikazu = kazu\n\nfor j in range(M):\n s, c = map(int,input().split())\n #print(s,c)\n for i in range(1000):\n if i not in kazu:\n pass\n else:\n if N + 1 - s == 1:\n if i % 10 != c:\n kazu.remove(i)\n #print('KKK')\n elif N + 1 - s == 2:\n if (i % 100) //10 != c:\n kazu.remove(i)\n #print('JJJ')\n else:\n if i // 100 != c:\n kazu.remove(i)\n #print('HHH')\nif len(kazu) == 0:\n pass\nelse:\n ans = kazu[0]\n\n\nprint(ans)\n\n\n \n\n"]
['Wrong Answer', 'Accepted']
['s716775377', 's455640897']
[3064.0, 3188.0]
[21.0, 21.0]
[817, 818]
p02761
u363421241
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["n, m = map(int, input().split())\nans = [0]*n\nfor _ in range(m):\n s, c = map(int, input().split())\n if ans[s-1] == 0:\n ans[s-1] = c\n else:\n print(-1)\n exit()\n\nans = [str(a) for a in ans]\nans = str(int(''.join(ans)))\nif len(ans) != n:\n print(-1)\nelse:\n print(ans)", 'n, m = map(int, input().split())\nsc = []\nfor _ in range(m):\n sc.append(list(map(int, input().split())))\n\n# print(sc)\nfor i in range(10**3):\n if len(str(i)) == n:\n cnt = 0\n for s, c in sc:\n if int(str(i)[s-1]) == c:\n cnt += 1\n if cnt == m:\n print(i)\n exit()\n\nprint(-1)']
['Wrong Answer', 'Accepted']
['s627783975', 's267957424']
[9056.0, 9052.0]
[30.0, 28.0]
[297, 342]
p02761
u363995337
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['\nN, M = map(int, input().split())\n\nC = []\nS = []\n\nfor i in range(M):\n c, s = map(int, input().split())\n C.append(c)\n S.append(s)\n\nfor x in range(1000):\n keta = 1\n nx = x//10\n d = [x%10]\n\n\n while(nx):\n keta += 1\n d.append(nx%10)\n nx = nx // 10\n d = list(reversed(d))\n\n isOk = True\n \n for i in range(M):\n if( d[C[i]-1] != S[i-1] ):\n isOk = False\n\n if isOk :\n num = "".join(map(str, d))\n print(num)\n return 0\n\nprint(-1)\nreturn 0', 'import sys\nN, M = map(int, input().split())\n\nC = []\nS = []\n\nfor i in range(M):\n c, s = map(int, input().split())\n C.append(c)\n S.append(s)\n\nfor x in range(1000):\n keta = 1\n nx = x//10\n d = [x%10]\n\n\n while(nx):\n keta += 1\n d.append(nx%10)\n nx = nx // 10\n d = list(reversed(d))\n\n isOk = True\n \n for i in range(M):\n if( d[C[i]-1] != S[i-1] ):\n isOk = False\n\n if isOk :\n num = "".join(map(str, d))\n break\n\nif isOk:\n print(num)\nelse:\n print(-1)', 'import sys\nN, M = map(int, input().split())\n\nC = []\nS = []\n\nfor i in range(M):\n c, s = map(int, input().split())\n C.append(c)\n S.append(s)\n\nfor x in range(1000):\n keta = 1\n nx = x//10\n d = [x%10]\n\n\n while(nx):\n keta += 1\n d.append(nx%10)\n nx = nx // 10\n d = list(reversed(d))\n\n isOk = True\n \n for i in range(M):\n if( d[C[i]-1] != S[i-1] ):\n isOk = False\n\n if isOk :\n num = "".join(map(str, d))\n print(num)\n sys.exit\n\nprint(-1)\nsys.exit', 'N, M = map(int, input().split())\n\nans = [0 for i in range(N)]\nisTerms = [0 for i in range(N)]\njadge = True\n\nfor i in range(M):\n s, c = map(int, input().split())\n if( ans[s-1] != c and isTerms[s-1] != 0):\n jadge = False\n elif( s == 1 and c == 0):\n jadge = False\n else:\n ans[s-1] = c\n isTerms[s-1] = 1\n\nif( N != 1 and ans[0] == 0 and jadge):\n ans[0] = 1\n\nif( N == 1 and ans[0] == 0):\n jadge = True\n\nif jadge:\n if(N==1):\n print(ans[0])\n else:\n for i in range(N-1):\n print(ans[i] ,end = "")\n print(ans[i+1])\nelse:\n print(-1)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s055447740', 's124013128', 's481426515', 's813455122']
[3064.0, 3064.0, 3188.0, 3064.0]
[18.0, 19.0, 21.0, 18.0]
[521, 534, 531, 607]
p02761
u368563078
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N,M = map(int, input().split())\nsets = []\nfor i in range(M):\n s,c = input().split()\n sets.append((s,c))\nfor n in range(10**(N-1), 10**N):\n for s,c in sets:\n if not str(n)[int(s)-1] == c:\n break\n else:\n print(n)\n break\nelse:\n print(-1)', 'N,M = map(int, input().split())\n \nsets = []\nfor i in range(M):\n s,c = input().split()\n sets.append((s,c))\n \nstart = 0\nif N != 1:\n start = 10**(N-1)\n \nfor n in range(start,10**N):\n for s,c in sets:\n if str(n)[int(s)-1] == c:\n continue\n else:\n break\n else:\n print(n)\n break\nelse:\n print(-1)']
['Wrong Answer', 'Accepted']
['s907263506', 's282494127']
[3060.0, 3064.0]
[17.0, 19.0]
[285, 316]
p02761
u368796742
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n,m = map(int,input().split())\nans = [-1]*n\n\nfor i in range(m):\n a,b = map(int,input().split())\n if a == 1 and b == 0:\n print(-1)\n exit()\n if ans[a-1] == -1:\n ans[a-1] = b\n else:\n if b != ans[a-1]:\n print(-1)\n exit()\nif n != 1 and ans[0] == -1:\n ans[0] = 1\nfor i in ans:\n if i == -1:\n print(0,end="")\n else:\n print(i,end="")\n', 'n,m = map(int,input().split())\nans = [0]*n\n\nl = [list(map(int,input().split())) for i in range(m)]\n\nfor i in range(1000):\n if len(str(i)) == n:\n \n check = True\n for j,k in l:\n if int(str(i)[j-1]) != k:\n check = False\n \n if check:\n print(i)\n exit()\nprint(-1)']
['Wrong Answer', 'Accepted']
['s101766093', 's217254289']
[3064.0, 3064.0]
[18.0, 19.0]
[410, 351]
p02761
u370721525
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['print(0)', 'print(-1)', 'N, M = map(int, input().split())\nans = -1\nli = []\n\nfor i in range(M):\n s, c = map(int, input().split())\n if not s, c = 1, 0:\n li.append([s, c])\n \nif N==1 and li!=[]:\n ans = 0\n \nfor i in range(10**(N-1), 10**N):\n j = 0\n while j < M:\n num = str(i)\n l = li[j]\n if num[l[0]-1] != str(l[1]):\n break;\n j += 1\n else:\n ans = i\n break;\n \nprint(ans)', 'def check(x):\n if len(str(x))!=N:\n return False\n for i in range(M):\n if str(x)[S[i]]!=str(C[i]):\n return False\n return True\n\nN,M=map(int,input().split())\nS=[]\nC=[]\nfor i in range(M):\n s,c=map(int,input().split())\n s-=1\n S.append(s)\n C.append(c)\n#print(S,C)\nfor i in range(1000):\n if check(i):\n print(i)\n exit() \nprint(-1) \n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s117621346', 's127096714', 's275923670', 's322127484']
[2940.0, 2940.0, 2940.0, 3064.0]
[17.0, 17.0, 17.0, 18.0]
[8, 9, 376, 353]
p02761
u373047809
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['\nn, m = map(int, input().split())\nL = [list(map(int,input().split())) for _ in range(m)] #s_i, c_i\n\nfor i in range(10**n): \n st = str(i)\n if len(i) == n and all(st[s-1] == str(c) for s, c in L): \n print(i)\n exit()\n\nprint(-1)', 'n, m = map(int, input().split())\nL = [list(map(int,input().split())) for _ in range(m)] #s_i, c_i\nj = 0 if n == 1 else 10**(n-1)\nfor i in range(j,10**n):\n st = str(i)\n if all(st[s-1] == str(c) for s, c in L): \n print(i)\n exit()\nprint(-1)']
['Runtime Error', 'Accepted']
['s488058933', 's781534798']
[3060.0, 3060.0]
[17.0, 18.0]
[379, 335]
p02761
u373295322
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['import sys\n\ndef get_minimun_val(n, rule_dict):\n max_val = 10**n\n min_val = 10**(n-1)\n if min_val = 1:\n min_val=0\n for i in range(min_val, max_val):\n str_i = str(i)\n flg = True\n for s, c in rule_dict.items():\n if str_i[s-1] == str(c):\n continue\n else:\n flg = False\n break\n if flg:\n return i\n return -1\n\n\nrule_dict = {}\n\nn, m = map(int, input().split())\nres = -1\nfor i in range(m):\n s, c = map(int, input().split())\n if c == 0 and s == 1 and n > 1:\n print(-1)\n sys.exit()\n if s not in rule_dict:\n rule_dict[s] = c\n continue\n current_c = rule_dict[s]\n if c != current_c:\n print(-1)\n sys.exit()\n\nprint(get_minimun_val(n, rule_dict))\n', ' import sys\n \n def get_minimun_val(n, rule_dict):\n max_val = 10**n\n min_val = 10**(n-1)\n for i in range(min_val, max_val):\n str_i = str(i)\n flg = True\n for s, c in rule_dict.items():\n if str_i[s-1] == str(c):\n continue\n else:\n flg = False\n break\n if flg:\n return i\n return -1\n \n \n rule_dict = {}\n \n n, m = map(int, input().split())\n res = -1\n for i in range(m):\n s, c = map(int, input().split())\n if c == 0 and s == 1:\n print(-1)\n sys.exit()\n if s not in rule_dict:\n rule_dict[s] = c\n continue\n current_c = rule_dict[s]\n if c != current_c:\n print(-1)\n sys.exit()\n \n print(get_minimun_val(n, rule_dict))', 'import sys\n\ndef get_minimun_val(n, rule_dict):\n max_val = 10**n\n min_val = 10**(n-1)\n if min_val == 1:\n min_val=0\n for i in range(min_val, max_val):\n str_i = str(i)\n flg = True\n for s, c in rule_dict.items():\n if str_i[s-1] == str(c):\n continue\n else:\n flg = False\n break\n if flg:\n return i\n return -1\n\n\nrule_dict = {}\n\nn, m = map(int, input().split())\nres = -1\nfor i in range(m):\n s, c = map(int, input().split())\n if c == 0 and s == 1 and n > 1:\n print(-1)\n sys.exit()\n if s not in rule_dict:\n rule_dict[s] = c\n continue\n current_c = rule_dict[s]\n if c != current_c:\n print(-1)\n sys.exit()\n\nprint(get_minimun_val(n, rule_dict))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s445901803', 's624308033', 's029992216']
[2940.0, 2940.0, 3064.0]
[17.0, 17.0, 17.0]
[708, 818, 709]
p02761
u374501720
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["n, m = map(int, input().split())\n\nif n == 1 and m == 0:\n print(0)\n exit()\n \nans = list(' '*n)\n\nfor i in range(m):\n a, b = map(int, input().split())\n \n if a==1 and b ==0:\n print(-1)\n exit()\n if ans[a-1] != ' ' and ans[a-1] != str(b):\n print(-1)\n exit()\n \n ans[a-1] = str(b)\n\n\nif ans[0] == ' ':\n ans[0] = '1'\nans = ''.join(ans)\nprint(ans)\nprint(int(ans.replace(' ', '0')))\n", "n, m = map(int, input().split())\n\nans = list(' '*n)\n\nfor i in range(m):\n a, b = map(int, input().split())\n \n if n != 1 and a==1 and b ==0:\n print(-1)\n exit()\n if ans[a-1] != ' ' and ans[a-1] != str(b):\n print(-1)\n exit()\n \n ans[a-1] = str(b)\n\nif ans[0] == ' ' and n != 1:\n ans[0] = '1'\nans = ''.join(ans)\n\nprint(int(ans.replace(' ', '0')))\n"]
['Wrong Answer', 'Accepted']
['s672920366', 's501792589']
[3064.0, 3064.0]
[19.0, 17.0]
[395, 361]
p02761
u374949588
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
[' coding: utf-8\n\nN, M = list(map(int, input().split()))\nbegin = 0 if N == 1 else 10**(N-1)\n\nsc = [[i for i in map(int, input().split())] for j in range(M)]\n\nfor i in range(begin, 10**N):\n flag = True\n for j in range(M):\n if str(i)[sc[j][0]-1] != str(sc[j][1]):\n flag = False\n break\n\n if flag == True:\n print(i)\n break\n\nif flag == False: print(-1)', '# coding: utf-8\n\nN, M = list(map(int, input().split()))\nbegin = 0 if N == 1 else 10**(N-1)\n\nsc = [[i for i in map(int, input().split())] for j in range(M)]\n\nfor i in range(begin, 10**N):\n flag = True\n for j in range(M):\n if str(i)[sc[j][0]-1] != str(sc[j][1]):\n flag = False\n break\n\n if flag == True:\n print(i)\n break\n\nif flag == False: print(-1)']
['Runtime Error', 'Accepted']
['s139743557', 's420012836']
[2940.0, 3064.0]
[17.0, 18.0]
[397, 398]
p02761
u375193358
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['import math\n\nN, M = map(int,input().split())\n\nif M == 0:\n if N == 1:\n print(0)\n else:\n print(10**(N-1))\nelse:\n s = list()\n c = list()\n\n for i in range(M):\n s_val, c_val = map(int, input().split())\n s.append(s_val)\n c.append(c_val)\n\n ans = 1000\n for i in range(int(10**(N)-1), int(10**(N-1)-1),-1):\n keta=list()\n for j in range(N):\n keta.append((math.floor(i/(10**j))%10))\n counter = 0\n print(i)\n for k in range(M):\n\n if keta[N-s[k]] == c[k]:\n counter += 1\n if counter == M:\n ans = i\n\n if N == 1 and M == 1 and c[0] == 0:\n print(0)\n\n elif ans == 1000:\n print(-1)\n else:\n print(ans)\n', 'import math\n\nN, M = map(int,input().split())\n\nif M == 0:\n if N == 1:\n print(0)\n else:\n print(10**(N-1))\nelse:\n s = list()\n c = list()\n\n for i in range(M):\n s_val, c_val = map(int, input().split())\n s.append(s_val)\n c.append(c_val)\n\n ans = 1000\n for i in range(int(10**(N)-1), int(10**(N-1)-1),-1):\n keta=list()\n for j in range(N):\n keta.append((math.floor(i/(10**j))%10))\n counter = 0\n print(i)\n for k in range(M):\n\n if keta[N-s[k]] == c[k]:\n counter += 1\n if counter == M:\n ans = i\n\n elif ans == 1000:\n print(-1)\n else:\n print(ans)\n', 'import math\n\nN, M = map(int,input().split())\n\nif M == 0:\n if N == 1:\n print(0)\n else:\n print(10**(N-1))\nelse:\n s = list()\n c = list()\n\n for i in range(M):\n s_val, c_val = map(int, input().split())\n s.append(s_val)\n c.append(c_val)\n\n ans = 1000\n for i in range(int(10**(N)-1), int(10**(N-1)-1),-1):\n keta=list()\n for j in range(N):\n keta.append((math.floor(i/(10**j))%10))\n counter = 0\n print(i)\n for k in range(M):\n\n if keta[N-s[k]] == c[k]:\n counter += 1\n if counter == M:\n ans = i\n\n if ans == 1000:\n print(-1)\n else:\n print(ans)\n', 'import math\n\nN, M = map(int,input().split())\n\nif M == 0:\n if N == 1:\n print(0)\n else:\n print(10**(N-1))\nelse:\n s = list()\n c = list()\n\n for i in range(M):\n s_val, c_val = map(int, input().split())\n s.append(s_val)\n c.append(c_val)\n\n ans = 1000\n for i in range(int(10**(N)-1), int(10**(N-1)-1),-1):\n keta=list()\n for j in range(N):\n keta.append((math.floor(i/(10**j))%10))\n counter = 0\n print(i)\n for k in range(M):\n\n if keta[N-s[k]] == c[k]:\n counter += 1\n if counter == M:\n ans = i\n\n if N == 1 and c[0] == 0:\n print(0)\n\n elif ans == 1000:\n print(-1)\n else:\n print(ans)\n', 'import math\n \nN, M = map(int,input().split())\n \nif M == 0:\n if N == 1:\n print(0)\n else:\n print(10**(N-1))\nelse:\n s = list()\n c = list()\n \n for i in range(M):\n s_val, c_val = map(int, input().split())\n s.append(s_val)\n c.append(c_val)\n \n ans = 1000\n for i in range(int(10**(N)-1), int(10**(N-1)-1),-1):\n keta=list()\n for j in range(N):\n keta.append((math.floor(i/(10**j))%10))\n counter = 0\n \n for k in range(M):\n \n if keta[N-s[k]] == c[k]:\n counter += 1\n if counter == M:\n ans = i\n \n if N == 1 and M == 1 and c[0] == 0:\n print(0)\n \n elif ans == 1000:\n print(-1)\n else:\n print(ans)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s323801017', 's353794960', 's502286384', 's536085645', 's496815479']
[3192.0, 3064.0, 3188.0, 3188.0, 3064.0]
[21.0, 18.0, 22.0, 21.0, 20.0]
[765, 707, 705, 754, 763]
p02761
u376754170
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['n, m = map(int, input().split())\nnums = [99] * n\n\nfor _ in range(m):\n n1, n2 = map(int, input().split())\n nums[n1-1] = min(nums[n1-1], n2)\n\n\nif nums[0] not in [99, 0]:\n print([x if x!=99 else 0 for x in nums])\nelse:\n print(-1)', 'n, m = map(int, input().split())\nrules = []\n\nfor x in range(m):\n rules.append(list(map(int, input().split())\n\ndef get_ans():\n if m == 0:\n return(10**(n-1)*int(bool(1<n)))\n\n for i in range(10**(n-1)*int(bool(1<n)), 10**n):\n for j, rule in enumerate(rules):\n\n if int(str(i)[rule[0]-1]) == rule[1]:\n if j == len(rules)-1:\n return(i)\n else:\n continue\n else:\n break\n return(-1)\n\n\nprint(get_ans()) \n', 'n, m = map(int, input().split())\nrules = [list(map(int, input().split())) for _ in range(m)]\n\ndef get_ans():\n if m == 0:\n return(10**(n-1)*int(bool(1<n)))\n \n for i in range(10**(n-1)*int(bool(1<n)), 10**n):\n for j, rule in enumerate(rules):\n \n if int(str(i)[rule[0]-1]) == rule[1]:\n if j == len(rules)-1:\n return(i)\n else:\n continue\n else:\n break\n \n return(-1)\n\n\nprint(get_ans())']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s483953424', 's990648392', 's189259068']
[9128.0, 9028.0, 9208.0]
[26.0, 24.0, 28.0]
[252, 521, 540]
p02761
u379142263
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['import sys\nn,m = map(int,input().split())\nans = [-1 for i in range(n)]\nfor i in range(m):\n s,c = map(int,input().split())\n s-=1\n if ans[s] == -1:\n ans[s] = c\n else:\n if c == ans[s]:\n continue\n else:\n print(-1)\n sys.exit()\n if n != 1:\n if ans[s] == 0:\n print(-1)\n sys.exit()\nfor i in range(n):\n if ans[i] == -1:\n ans[i] = 0\nfans = ""\nfor i in range(n):\n fans += ans[i]\nprint(fans)\n', "import sys\nn,m = map(int,input().split())\nans = [-1 for i in range(n)]\ncheck = [0 for i in range(n)]\nif n == 1:\n s,c = map(int,input().split())\n print(c)\n sys.exit()\nelse:\n for i in range(m):\n s,c = map(int,input().split())\n if ans[s-1] == -1:\n ans[s-1] = c\n else:\n if c == ans[s-1]:\n continue\n else:\n print(-1)\n sys.exit()\n if s-1 == 0:\n if c == 0:\n print(-1)\n sys.exit()\n for i in range(1,n+1):\n if ans[i] == -1:\n ans[i] = 0\n if ans[0] == -1:\n ans[0] = 1\n ans2 = ''\n for i in range(n):\n ans2 += str(ans[i])\n print(ans2)", 'import sys\nn,m = map(int,input().split())\nans = [-1 for i in range(n)]\nfor i in range(m):\n s,c = map(int,input().split())\n s-=1\n if ans[s] == -1:\n ans[s] = c\n else:\n if c == ans[s]:\n continue\n else:\n print(-1)\n sys.exit()\nif n != 1:\n if ans[0] == 0:\n print(-1)\n sys.exit()\n else:\n if ans[0] == -1:\n ans[0] = 1\n for i in range(n):\n if ans[i] == -1:\n ans[i] = 0\nelse:\n for i in range(n):\n if ans[i] == -1:\n ans[i] = 0\nfans = ""\nfor i in range(n):\n fans+=str(ans[i])\nprint(fans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s375547175', 's392841049', 's053177718']
[3064.0, 3064.0, 3064.0]
[17.0, 18.0, 18.0]
[491, 727, 636]
p02761
u379692329
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["N, M = map(int, input().split())\ncond = [list(map(int, input().split())) for _ in range(M)]\nflag = True\nans = [-1]*N\n\nif M == 0:\n if N == 1:\n print(0)\n else:\n print('1'+'0'*(N-1))\nelse:\n for i in cond:\n digit = i[0]-1\n if digit > N-1:\n flag = False\n break\n elif ans[digit] != -1 and ans[digit] != i[1]:\n flag = False\n break\n elif i == [1, 0] and N > 1:\n flag = False\n break\n else:\n ans[digit] = i[1]\n\n if flag:\n if ans[0] == -1:\n ans[0] = 1\n \n for i in range(1, N):\n if ans[i] == -1:\n ans[i] = 0\n \n print(''.join(map(str, ans)))\n else:\n print(-1)", "N, M = map(int, input().split())\ncond = [list(map(int, input().split())) for _ in range(M)]\nflag = True\nans = [-1]*N\n\nif M == 0:\n if N == 1:\n print(0)\n else:\n print('1'+'0'*(N-1))\nelse:\n for i in cond:\n digit = i[0]-1\n if digit > N-1:\n flag = False\n break\n elif ans[digit] != -1 and ans[digit] != i[1]:\n flag = False\n break\n elif i == [1, 0] and N > 1:\n flag = False\n break\n else:\n ans[digit] = i[1]\n\n if flag:\n if ans[0] == -1:\n ans[0] = 1\n \n for i in range(1, N):\n if ans[i] == -1:\n ans[i] = 0\n \n print(''.join(map(str, ans)))\n else:\n print(-1)"]
['Runtime Error', 'Accepted']
['s292270738', 's029580288']
[2940.0, 3192.0]
[17.0, 19.0]
[718, 766]
p02761
u379959788
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
['N, M = map(int, input().split())\nsc = [list(map(int, input().split())) for _ in range(M)]\nsc = list(map(list, set(map(tuple, sc))))\nM = len(sc)\nprint(M)\ntmp = [-1] * N\nfor i in range(M):\n if tmp[sc[i][0]-1] == -1:\n tmp[sc[i][0]-1] = sc[i][1]\n else:\n print(-1)\n exit()\n if sc[i][0] == 1 and sc[i][1] == 0:\n print(-1)\n exit()\nif tmp[0] == -1:\n tmp[0] = 1\nans = ""\nfor i in range(N):\n if tmp[i] == -1:\n ans += "0"\n else:\n ans += str(tmp[i])\nprint(int(ans))', 'N, M = map(int, input().split())\nsc = [list(map(int, input().split())) for _ in range(M)]\nsc = list(map(list, set(map(tuple, sc))))\nM = len(sc)\nif N == 1:\n if M == 1:\n print(sc[0][1])\n exit()\n if M == 0:\n print(0)\n exit()\n\ntmp = [-1] * N\nfor i in range(M):\n if sc[i][0] == 1 and sc[i][1] == 0:\n print(-1)\n exit()\n\n if tmp[sc[i][0]-1] == -1:\n tmp[sc[i][0]-1] = sc[i][1]\n else:\n print(-1)\n exit()\n\nif tmp[0] == -1:\n tmp[0] = 1\nans = ""\nfor i in range(N):\n if tmp[i] == -1:\n ans += "0"\n else:\n ans += str(tmp[i])\nprint(int(ans))']
['Wrong Answer', 'Accepted']
['s773025511', 's578798346']
[3064.0, 3064.0]
[18.0, 17.0]
[520, 626]
p02761
u380995377
2,000
1,048,576
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
["N,M = [int(i) for i in input().split()]\nd = {}\nfor i in range(M):\n s,c = [int(i) for i in input().split()]\n if d.get(s,c) != c:\n print(-1)\n break\n else:\n d[s] = c\nelse:\n if d[1] == 0:\n print(-1)\n else:\n l=[str(d.get(1,1))]\n l=[str(d.get(i,0)) for i in range(2, N+1)]\n print(''.join(l))\n", "N,M = [int(i) for i in input().split()]\nd = {}\nfor i in range(M):\n s,c = [int(i) for i in input().split()]\n if d.get(s,c) != c:\n print(-1)\n break\n else:\n d[s] = c\nelse:\n if N==1:\n print(d.get(1,0))\n elif d.get(1,1) == 0:\n print(-1)\n else:\n l = [str(d.get(1,1))]\n l+=[str(d.get(i,0)) for i in range(2, N+1)]\n print(''.join(l))\n"]
['Runtime Error', 'Accepted']
['s612439346', 's969396407']
[3064.0, 3064.0]
[18.0, 17.0]
[350, 400]