peterverebics/CodeNet_Python_118 huggingface dataset:
n, m = map(int, input().split())
sc = [[i for i in map(int, input().split())] for j in range(m)]
start = 0
goal = 0
if n == 1:
    start = 0
    goal = 9
elif n == 2:
    start = 10
    goal = 99
elif n == 3:
    start = 100
    goal = 999

flag = 1
ans = -1
for num in range(start, goal + 1):
    flag = 1
    for i in range(m):
        if str(num)[sc[i][0] - 1] != str(sc[i][1]):  # 両辺ともちゃんとstrで変換
            flag = 0
    if flag == 1:
        ans = num
        break

print(ans)
N,M=map(int,input().split())
d=[-1 for _ in range(N)]
for m in range(M):
  s,c=map(int,input().split())
  if d[s-1]==-1:
    d[s-1]=c
  elif d[s-1]!=c:
    print(-1)
    exit()

if N>1:
  if d[0]==0:
    print(-1)
    exit()
  elif d[0]==-1:
  	d[0]=1

A=0
for i in range(N):
  A=A*10+(d[i] if d[i]!=-1 else 0)

print(A)
N, M = map(int, input().split())
S = [-1] * N
for _ in range(M):
  s, c = map(int, input().split())
  if S[s-1] != -1 and S[s-1] != c:
    print (-1)
    break
  else:
    S[s-1] = c
else:
  if S[0] == 0 and len(S) > 1:
    print (-1)
  else:
    if S[0] == -1:
      if len(S) > 1:S[0] = 1
      else: S[0] = 0
    for i in range(N):
      print (S[i] if S[i] != -1 else 0, end="")
import sys

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()

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

for i in range(0, 1000):
    x = str(i)
    if len(x) == N and all(x[s] == c for s, c in constraints):
        print(x)
        exit(0)

print(-1)
n,m = map(int,input().split())
data = [list(map(int,input().split())) for _ in range(m)]

for ans in range(1000):
    if len(str(ans)) == n:
        t = True
        for s,c in data:
            if s <= n and str(ans)[s-1] == str(c):
                continue
            else:
                t = False
                break
        if t:
            print(ans)
            exit()

print(-1)
n, m = map(int, input().split())

num = [-1 for _ in range(n)]

for _ in range(m):
    s, c = map(int, input().split())
    s -= 1

    if n >= 2 and s == 0 and c == 0:
        print(-1)
        exit()
    
    elif  num[s] != -1 and num[s] != c:
        print(-1)
        exit()
    else:
        num[s] = c

if num[0] == -1 and n != 1:
    num[0] = 1
elif num[0] == -1 and n == 1:
    num[0] = 0

num = ["0" if n == -1 else str(n) for n in num]

print("".join(num))
N, M = map(int, input().split())
X = [-1] * (N + 1)
flag = False
for i in range(M):
    s, c = map(int, input().split())
    if X[s] == -1:
        X[s] = c
    else:
        if c != X[s]:
            flag = True

X = X[1:]
if len(X) > 1 and X[0] == 0:
    flag = True

if flag:
    print(-1)
else:
    if len(X) > 1 and X[0] == -1:
        X[0] = 1
    X = [('0' if i == -1 else str(i)) for i in X]
    print(''.join(X))
N, M = map(int,input().split())
s = []
c = []
for i in range(M):
  S, C = map(int,input().split())
  s.append(S)
  c.append(C)


for i in range(10 ** (N + 1)):
  Str = str(i)

  if len(Str) == N and all([Str[s[j] - 1] == str(c[j]) for j in range(M)]):
      print(Str)
      exit()

print(-1)
N, M = map(int, input().split())
ans = [-1]*N
reg = [list(map(int, input().split())) for _ in range(M)]
answer = True
for s, c in reg:
  if ans[s-1]!=-1 and ans[s-1]!=c:
    answer = False
    break
  else:
    ans[s-1]=c
if not answer:
  print(-1)
elif N==1 and M==0:
  print(0)
elif ans[0]==0 and N!=1:
  print(-1)
else:
  for i in range(N):
    if i==0 and ans[0]==-1:
      ans[0]=1
    elif ans[i]==-1:
      ans[i]=0
  print(int(''.join([str(i) for i in ans])))
N, M = map(int, input().split())
flag = True
ex = [-1]*N
for i in range(M):
  S,C = map(int, input().split())
  if ex[S-1]==-1 or ex[S-1]==C:
    ex[S-1] = C
  else:
    flag = False
    break
if N>1 and ex[0]==0:
  flag = False
if flag:
  for i in range(1,N):
    if ex[i]==-1:
      ex[i] = 0
  if ex[0]==-1 and N>1:
    ex[0] = 1
  elif ex[0]==-1:
    ex[0] = 0
  print(int("".join(map(str, ex))))
else:
  print(-1)
def main():
    n, m = map(int, input().split())
    sc_list = [list(map(int, input().split())) for _ in range(m)]
    ans = []
    for i in range(0, 10 ** n):
        tmp = str(i)
        if n == len(tmp):
            if all([tmp[s - 1] == str(c) for s, c in sc_list]):
                ans.append(i)
    if not ans:
        print(-1)
    else:
        print(min(ans))
main()
n,m=map(int,input().split())
sc=[tuple(map(int,input().split())) for _ in range(m)]
for i in range(1000):
  if not len(str(i))==n:
    continue
  for s,c in sc:
    if not str(i)[s-1]==str(c):
      break
  else:
    print(i)
    exit()
print(-1)
n,m=map(int,input().split())
num=[0 for i in range(n)]
for i in range(m):
  s,c=map(int,input().split())
  if s>n:
    num[0]=-1
  if n>1 and s==1 and c==0:
    num[0]=-1
  elif num[s-1]==0 or num[s-1]==c:
    num[s-1]=c
  else:
    num[0]=-1 
if num[0]==0:
  if n>1:
    num[0]=1
#print('    ',num)
moji=''
if min(num)>=0:  
  for i in range(n):
    moji+=str(num[i])
  print(int(moji))
else:
  print(-1)
n,m = list(map(int,input().split()))
ans = [-1] * n
total = 0
  
for i in range(m):
  s,c = list(map(int,input().split()))
  if ans[s-1] != -1 and ans[s-1] != c:
    print(-1)
    exit()
  
  else:
    ans[s-1] = c
  
if ans[0] == 0 and n >= 2:
  print(-1)
  exit()
  
elif ans[0] == -1 and n >= 2:
  ans[0] = 1
  
for i in range(n):
  if ans[i] == -1:
    ans[i] = 0
    
a = 0  
for i in range(n-1, -1, -1):
  total += ans[i] * 10**a
  a += 1

print(total)
N,M = map(int,input().split())
sl = [list(map(int,input().split())) for _ in range(M)]

startnum = 0 if N==1 else 10**(N-1)

for i in range(startnum,10**N):
    str_i = str(i)
    count = 0
    for s,c in sl: 
        if(str_i[s-1]==str(c)):
            count += 1
    
    if(count==len(sl)):
        print(i)
        exit(0)

print(-1)
n, m = map(int, input().split())

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

ans = [-1] * n


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

    else:
        ans[s] = c

if ans[0] == 0 and n >= 2:
    print(-1)
    exit()

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

a = ""
for i in ans:
    a += str(i) if i != -1 else "0"
print(a)
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]
i = 10**(N-1) if N > 1 else 0
while i < 10**N:
  n = [(i//10**j)%10  for j in reversed(list(range(N)))]
  f = True
  for s, c in SC:
    if n[s-1] != c:
      f = False
  if f:
    break
  i += 1
if i >= 10**N:
  print(-1)
else:
  print(i)
n, m = map(int, input().split())

imp = 0
num = [0]*n

for i in range(m):
  c, a = map(int, input().split())
  if c==1 and n!=1 and a==0:
    imp = 1
  if c>n:
    imp = 1
  if num[c-1]>0 and num[c-1]!=a:
    imp = 1
  else:
    num[c-1] = a

if n>1 and num[0]==0:
  num[0] = 1

num = [str(i) for i in num]

if imp:
  print(-1)
else:
  print(int(''.join(num)))
n,m = map(int,input().split())
s = []
c = []

ans = ['0' for i in range(n)]
f = True
for i in range(m):
    ss,cc = map(int,input().split())
    for l,o in enumerate(s):
        if s[l] == ss and c[l] != cc:
            f = False
    if ss == 1 and cc == 0 and n != 1:
        f = False
    s.append(ss)
    c.append(cc)

for i,o in enumerate(s):
    ans[o-1] = str(c[i])

if ans[0] == str(0) and n!=1:
    ans[0] = str(1)

if f == False:
    print('-1')
else:
    print(''.join(ans))
n, m = map(int, input().split())
num = [None] * n
a = [tuple(map(int, input().split())) for _ in range(m)]
for pos, val in a:
    if num[pos - 1] != None and num[pos - 1] != val:
        print(-1)
        exit()
    num[pos - 1] = val
if n == 1 and num[0] == None:
    num[0] = 0
canBeZero = False
for i in range(n):
    if num[i] == None:
        num[i] = 0 if canBeZero else 1
    if num[i]:
        canBeZero = True
ret = str(int(''.join(map(str, num))))
print(ret if len(ret) == n else -1)
n,m = map(int,input().split())
num = [-1]*n
for i in range(m):
  s,c = map(int,input().split())
  if n!=1 and s==1 and c==0:
    print(-1)
    exit()
  if num[s-1]==-1: num[s-1] = c
  elif num[s-1]!=c:
    print(-1)
    exit()
for i in range(n):
  if num[i] == -1: num[i] = 0
if num[0] == 0 and len(num)!=1: num[0] = 1
for i in range(n):
  print(num[i],end='')
N, M = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(M)]

for i in range(1000):
    s = str(i)
    if len(s) != N:
        continue

    flg = True
    for j in range(len(arr)):
        if s[arr[j][0]-1] != str(arr[j][1]):
            flg = False
            break

    if flg:
        print(i)
        exit()

print(-1)
N, M = map(int, input().split())
ans = ["0"] * (N)
Flag = True

for i in range(M):
  s, c = map(int, input().split())
  if ans[s-1] == "0":
    ans[s-1] = c
  elif ans[s-1] == c:
    continue
  else:
    Flag = False

if N > 1:
  if ans[0] == 0:
    Flag = False
  elif ans[0] == "0":
    ans[0] = 1

if Flag:
  print(int("".join([str(i) for i in ans])))
else:
  print(-1)
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
cur = [list(map(int, input().split())) for _ in range(M)]

def check(n):
    if len(str(n)) != N:
        return False
    ok = True
    for pos, val in cur:
        ok &= str(n)[pos - 1] == str(val)
    return ok

i = 0
for i in range(10 ** N):
    if check(i):
        print(i)
        exit()
print(-1)
# Code for C - Guess The Number
# Use input() to fetch data from STDIN
import sys
[n, m] = [int(x) for x in input().split()]
s = []
c = []

for i in range(m):
    [x, y] = [int(x) for x in input().split()]
    s.append(x)
    c.append(y)

for x in range(1000):
    a = str(x)
    if len(a) != n:
        continue

    test = all([a[i - 1] == str(j) for i, j in zip(s, c)])
    if test:
        print(x)
        sys.exit()

print("-1")
n, m = map(int, input().split())
sc_list = [list(input().split()) for _ in range(m)]
ans = -1
for i in range(10**n):
    if len(str(i)) != n:
        continue
    else:
        count = 0
        s = str(i)
        for sc in sc_list:
            if s[int(sc[0])-1] == sc[1]: 
                count += 1
        if count == m:
            ans = i
            break
print(ans)
N, M = map(int, input().split())
arr = []
ans = [0] * N
if N > 1:
    ans[0] = 1
for i in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and N != 1:
        print(-1)
        exit(0)
    if s in arr and ans[s-1] != c:
        print(-1)
        exit(0)
    arr.append(s)
    ans[s-1] = c
print("".join([str(i) for i in ans]))
n, m = map(int, input().split())
ans = [0] * n
cklist = [0] * n
result = True
for x in range(m):
    s, c = map(int, input().split())
    if n != 1 and s == 1 and c == 0: 
        print(-1)
        result = False
        break
    elif cklist[s - 1] == 1 and ans[s - 1] != c:
        print(-1)
        result = False
        break
    else:
        ans[s - 1] = c
        cklist[s - 1] = 1
ans_str = [str(n) for n in ans]
if(result == True): print(''.join(ans_str))
n, m=map(int, input().split())
a = [-1]*n
ans = 0
for i in range(m):
  s, c = map(int, input().split())
  if a[s-1]!=c and a[s-1]!=-1:
    ans = -1
    break
  elif n>1 and s==1 and c==0:
    ans = -1
    break
  else:
    a[s-1]=c
if ans == 0:
  if a[0]==-1:
    a[0]=1
  for i in range(n):
    if a[n-1-i] != -1:
      ans += a[n-1-i]*10**i
print(ans)
N,M = input().split(' ')
numlist = []
for i in range(int(N)):
    numlist.append('0')
for i in range(int(M)):
    S,C = input().split(' ')
    numlist[int(S)-1] = C
num = ''.join(numlist)
num = int(num)
if len(str(num)) == int(N):
    print(int(num))
elif N == 1 & num == 0:
    print(0)
else:
    print(-1)
N, M = map(int, input().split(" "))
ans = [-1 for i in range(N)]
is_conflict = False

for i in range(M):
    s, c = map(int, input().split(" "))
    if ans[s - 1] == -1:
        ans[s - 1] = c
    else:
        is_conflict |= (ans[s - 1] != c)

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

if len(str(int(''.join([str(a) for a in ans])))) != N or is_conflict:
    print(-1)
else:
    print(''.join([str(a) for a in ans]))
f=0
N, M = map(int, input().split())
list = []
for i in range(M):
    a,b=input().split()
    list.append((int(a), int(b)))

for i in range(1000):
	f=0
	for j in range(M):
		if int(i/(10**(N-list[j][0])))%10 != list[j][1]:
			f=1
			break
	if f==0:
		print(i)
		break
		
if f==1:
	print(-1)
N,M=map(int,input().split())
sc=[list(map(int,input().split()))for _ in [0]*M]

ans=['1']+['0']*(N-1)
count=[0]*N
for s,c in sc:
    if count[s-1]==1 and ans[s-1]!=str(c):
        ans='-1'
        break
    else:
        ans[s-1]=str(c)
        count[s-1]=1

if N>=2 and ans[0]=='0':
    ans='-1'

if M==0:
    ans='0'

print(''.join(ans))
f=lambda:map(int,input().split())
N,M=f()
q=[list(f()) for _ in [0]*M]
res=-1
for i in range(10**(N-1),10**N):
    for j in range(M):
        if str(i)[q[j][0]-1]!=str(q[j][1]):
            break
    else:
        res=i
        break
print(res)
N, M = map(int, input().split())
sc = []
tf = True
for i in range(M):
  sc.append(list(map(int, input().strip().split())))
num = []
for i in range(N):
  num.append(0)
sc.sort()
for i in range(M-1):
  if sc[i][0] == sc[i+1][0] and sc[i][1] != sc[i+1][1]:
    tf = False
for i in sc:
  if i[0] == 1 and i[1] == 0:
    tf = False
  else:
    num[i[0]-1] = i[1]
if tf and num[0] == 0:
  num[0] = 1
string = ""
for i in num:
  string += str(i)
if tf == True:
  print(string)
else:
  print(-1)
N,M = map(int, input().split())

sets = []
for i in range(M):
  s,c = input().split()
  sets.append((s,c))
  
for n in range(10**(N-1), 10**N-1):
  for s,c in sets:
    if not str(n)[int(s)-1] == c:
      break
  else:
    print(n)
    break
else:
  print(-1)
N, M = map(int, input().split())
SC = [[int(x) for x in input().split()] for _ in range(M)]

ans = [0] * N
flg = 0

for s, c in SC:
    if (flg>>(s-1))&1:
        ans[s-1] = min(ans[s-1], c)
    else:
        flg |= 1<<(s-1)
        ans[s-1] = c


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

if len(ans)!=N:
    print(-1)
else:
    print(ans)
from collections import defaultdict
n,m = map(int,input().split())
ans = []
flag = True
b = defaultdict(list)
for i in range(n):
    ans.append('0')
for i in range(m):
    s,c = map(int,input().split())
    c = str(c)
    b[s].append(c)
for key,value in b.items():
    if len(set(value)) == 1:
        ans[key-1] = value[0]
    else:
        flag = False
tmp = ''
for idx,i in enumerate(ans):
    if idx == 0 and i == '0' and len(ans) != 1:
        flag = False
    tmp += i
print(tmp if len(tmp) == n and flag else -1)
N,M=map(int,input().split())
nums={}
for i in range(M):
    s,c=map(str,input().split())
    if s in nums.keys():
        if nums[s]!=c:
            ans=-1
            print(ans)
            exit()
    else:
        nums[s]=c
for i in range(1,N+1):
    if str(i) not in nums.keys():
        nums[str(i)]='0'
n=[]
for i in sorted(nums):
    n.append(nums[i])
ans=int(''.join(n))
if len(list(str(ans)))!=N:
    ans=-1
print(ans)
N, M = map(int, input().split())
S_C_list = [[int(_) for _ in input().split()] for i in range(M)]

ans = '0' * N
for i_s, i_c in S_C_list:
    if ans[i_s-1] == '0' or ans[i_s-1] == str(i_c):
        ans = ans[:i_s-1] + str(i_c) + ans[i_s:]
        continue

    ans = '-1'
    break

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

print(int(ans))
N,M = map(int,input().split())
e = 0
li = [0]* N
for i in range(M):
    s,c = map(int,input().split())
    s -= 1
    if li[s] == 0:
        li[s] = c
    if li[s] != c:
        e = 1
    if (s == 1) and (c == 0):
        e = 1
if li[0] == 0:
    li[0] = 1
if e == 1:
    print("-1")
    exit()
a = ""
for i in li:
    a += str(i)
print(a)
import sys
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())

D = [-1] * N

for _ in range(M):
    s, c = map(int, input().split())

    if D[s-1] == -1 or D[s-1] == c:
        D[s-1] = c
    else:
        print('-1')
        exit()

if D[0] == -1:
    D[0] = 1
elif D[0] == 0:
    print('-1')
    exit()

ans = []

for d in D:
    if d == -1:
        ans.append(str(0))
    else:
        ans.append(str(d))

# print(ans)
print(''.join(ans))
N,M = map(int,input().split())

d = {}
total = 0
for i in range(M):
  s,c = map(int,input().split())
  if s in d and d[s] < c:
    continue
  else:
    d[s] = c   

for a,b in d.items():    
    total += b * 10**(N-a)    
    
if len(str(total)) != N:
  print(-1)
else:
  print(total)
n, m = map(int, input().split())

num = [0] * n
for i in range(m):
    s, c = map(int, input().split())
    if num[s - 1] == 0:
        num[s - 1] = c
    else:
        num[s - 1] = min(num[s - 1], c)
    
if num[0] == 0:
    print(-1)
else:
    for i in range(n):
        print(num[i], end="")
n, m = map(int, input().split())

l = [-1] * n

for _ in range(m):
    s, c = map(int, input().split())
    s -= 1

    if l[s] == -1:
        l[s] = c

    elif l[s] != c:
        print(-1)
        exit()

if n > 1 and l[0] == 0:
    print(-1)
    exit()

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

for i in range(n):
    if l[i] == -1:
        l[i] = 0

print(*l, sep='')
N,M=map(int,input().split())
INF=float("inf")
num=[INF]*N
ans=""
for i in range(M):
    s,c=map(int,input().split())
    if s==1 and c==0:
        print(-1);exit()
    if num[s-1]==INF or num[s-1]==c:
        num[s-1]=c
    else:
        print(-1);exit()
for k in range(1,N):
    if num[k]==INF:
        num[k]=0
if num[0]==INF:
    num[0]=1
for k in range(N):
    ans+=str(num[k])
print(ans)
n,m = map(int,input().split())
ans = list()
sc_list = [list(map(str,input().split())) for _ in range(m)]
if n == 0:
    j = 0
else:
    j = 10 ** n
for k in range(j,10 ** n):
    st = str(i)
    for s,c in sc_list:
        if st[s] != c:
            break
    else:
        print(st)
        exit()
else:
    print('-1')
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

ans = [0 for _ in range(n)]
one = False
for x in sc:
    p = x[0]-1
    if p == 0:
        one = True
    if ans[p] == 0 or ans[p] >= x[1]:
        ans[p] = x[1]
if not one:
    print(-1)
    exit()
num = ''
for x in ans:
    num += str(x)
print(int(num) if len(str(int(num))) == n else -1)
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

ans = [-1] * n

for s, c in sc:
    t = s - 1
    if ans[t] == -1:
        ans[t] = c
    elif ans[t] != c:
        print(-1)
        exit()

if ans[0] == 0:
    if n == 1:
        print(0)
    else:
        print(-1)
    exit()
ans[0] = str(max(1, ans[0]))
for i in range(1, n):
    ans[i] = str(max(0, ans[i]))

print(''.join(ans))
from collections import defaultdict
N,M = map(int,input().split())
cand = defaultdict(set)

for i in range(M):
  s,c = map(int,input().split())
  cand[s].add(c)

ans = ""
for i in range(1,N+1):
  if cand[i]:
    if len(cand[i])>1:
      print(-1)
      exit()
    else:
      for j in cand[i]:
          ans += str(j)
  else:
    ans += "0"
                    
if ans[0]== "0":
  print(-1)
else:
  print(ans)
N,M=map(int,input().split())
l=[0]*N
ans=0
for i in range(M):
    s,c=map(int,input().split())
    if l[s-1]==0 or l[s-1]==c:
        l[s-1]=c
    else:
        print(-1)
        exit()
for i in range(N):
    ans+=int(l[i])*(10**(N-i-1))
if N==len(str(ans)):
    print(ans)
else:
    print(-1)
N, M = map(int, input().strip().split())
A = [None for _ in range(N)]
for _ in range(M):
  s, c = map(int, input().strip().split())
  if A[s-1] is None:
    A[s-1] = c
  else:
    if A[s-1] != c:
      A[s-1] = min(c, A[s-1])

if A[0] is None or (len(A) >= 2 and A[0] == 0):
  print(-1)
  exit()
A = [str(e) if e else '0' for e in A]
print(''.join(A))
import sys
n,m = map(int, input().split())
num = [0]*n
Ans = 0
for i in range(m):
    s,c = map(int, input().split())
    if num[s-1] != 0 and num[s-1] != c:
        print(-1)
        sys.exit()
    else:
        num[s-1] = c
if num.count(0)==n:
    print(-1)
    sys.exit()
if num[0] == 0:
    num[0] = 1
for i in range(len(num)):
    Ans = Ans + num[i] * (10 ** (n-i-1))

if Ans == 0:
    print(-1)
else:
    print(Ans)
n,m = map(int,input().split())
s = []
c = []
ans = [0]*n
for _ in range(m):
  st,ct = map(int,input().split())
  s.append(st)
  c.append(ct)

f = 1
for i in range(m):
  if s[i] == 1 and c[i] == 0:
    f = 0
    break
  if ans[s[i]-1] != 0 and ans[s[i]-1] != c[i]:
    f = 0
    break
  ans[s[i]-1] = c[i]
if f == 0:
  print(-1)
else:
  print(''.join(map(str,ans)))
N,M = map(int,input().split())
A = ['a']*N
for _ in range(M):
  s,c = map(int,input().split())
  if A[s-1] !='a' and A[s-1] != c:
    print(-1)
    exit()
  else:
    A[s-1] = c

for i in range(N):
  if A[0] == 'a' and N==3:
    A[0] = 1
  elif A[i] == 'a':
    A[i] = 0
Answer = ''.join(map(str,A))

if Answer != '0' and len(Answer) != N:
  Answer = -1
if Answer == '000':
  Answer = -1
print(Answer)
n,m = map(int, input().split())
ans = [None] *n
f= 0
for i in range(m):
    s,c = map(int, input().split())
    if (ans[s-1] != None) and (ans[s-1] != c):  # 重複
        f = 1
    ans[s-1] = c

if f == 1:
    print('-1')
    exit()
elif ans[0] == None:
    ans[0] == 1
elif ans[0] == 0 and len(ans) != 1:
    print('-1')
    exit()

for i in range(n):
    if ans[i] == None:
        ans[i] = 0
print(''.join(map(str, ans)))
import sys

n,m = map(int,input().split())
suuji = ['0'  for i in range(n)]
# print(suuji)
for i in range(m):
    a,b = map(int,input().split())
    if suuji[a-1]=='0' or suuji[a-1]==str(b):
        suuji[a-1]=str(b)
    else:
        print(-1)
        sys.exit()

if suuji[0] != '0':
    ans = int(''.join(suuji))
else:
    ans = -1

print(ans)
N,M=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]
import sys
S=[-1 for i in range(N)]
visited=[[] for i in range(N)]

for i in A:
    S[i[0]-1]=i[1]
    visited[i[0]-1].append(i[1])
for i in visited:
    if len(set(i))>1:
        print(-1)
        sys.exit()
if S[0]==0:
    print(-1)
    sys.exit()
if S[0]==-1:
    S[0]=1

for i,value in enumerate(S):
    if value==-1:
        S[i]=0

print(*S,sep='')
n, m = map(int, input().split())

listans = ["0"] * n
ans = 0

for i in range(m):
    s, c = map(str, input().split())
    if s == "1" and c == "0":
        ans = -1
    if listans[int(s)-1] != c:
        if listans[int(s)-1] == "0":
            listans[int(s)-1] = c
        else :
            ans = -1

if ans == 0:
    if listans[0] == "0":
        listans[0] = "1"
    ans = int("".join(listans))

print(ans)
N, M = [int(x) for x in input().split()]

S = []
for i in range(N):
    S.append(None)

for i in range(M):
    s, c = [int(x) for x in input().split()]
    
    if S[s - 1] == None:
        S[s - 1] = c
    elif S[s - 1] == c:
        pass
    else:
        S[0] = 0
        break

if S[0] == 0 and N > 1:
    print(-1)
else:
    for s in S:
        if s == None:
            s = '0'
        print(s, end="")
print()
N, M = list(map(int, input().split()))
suuji = [-1 for _ in range(N)]

for _ in range(M):
  s, c = list(map(int, input().split()))
  if any([suuji[s-1] not in [-1, c], s > N, all([s==1, c==0, N>1])]):
    print(-1)
    break
  else:
    suuji[s-1] = c
else:
  if suuji[0] == -1:
    suuji[0] = 1
  for i in range(N):
    if suuji[i] == -1:
      suuji[i] = 0
  print(int(''.join([str(i) for i in suuji])))
n,m = [int(x) for x in input().split()]
li = list()
for i in range(m):
    li.append([int(x) for x in input().split()])

for i in range(1000):
    length = len(str(i))
    for j in li:
        if (length<j[0] or length != n):
            break
        if (str(i)[j[0]-1] != str(j[1])):
            break
    else :
        print(i)
        break
else:
    print("-1")
n, m = map(int, input().split())
s = "0" * n
flag = 0

for _ in range(m):
    a, b = map(int, input().split())

    if s[a - 1] != '0':
        if s[a - 1] != str(b):
            flag = 1
    
    s = s[:a-1] + str(b) + s[a:]

if flag == 0:
    if n == 1:
        print(s)
    elif int(s) >= 10 ** (n - 1):
        print(s)
    else:
        print(-1)
else:
    print(-1)