Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

for i in range(10 * N):
    num = str(i)
    flag = True
    for pair in sc:
        if (num[pair[0] - 1] != pair[1]) or len(num) < pair[0]:
            flag = False
            break
    if flag:
        ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

Fixed submission:
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

for i in range(10 * N):
    num = str(i)
    flag = True
    for pair in sc:
        if (num[pair[0] - 1] != pair[1]) or len(i) < pair[0]:
            flag = False
            break
    if flag:
        ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

Fixed submission:
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

Buggy python submission (verdict: Runtime Error):
def solve():
    N, M = map(int, input().split())
    d = {}

    if N == 1:
        for i in range(M):
            s, c = map(int, input().split())
            if (s in d and d[s] != c):
                return -1
            else:
                d[s] = c
        return d[1]

    for i in range(M):
        s, c = map(int, input().split())
        if (s in d and d[s] != c) or (s == 1 and c == 0):
            return -1
        else:
            d[s] = c
    
    ans = [0] * N
    for key, val in d.items():
        ans[key - 1] = val
    if ans[0] == 0:
        ans[0] = 1
    ans = [str(c) for c in ans]

    return "".join(ans)

print(solve())

Fixed submission:
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

Buggy python submission (verdict: Runtime Error):
def solve():
    N, M = map(int, input().split())
    d = {}

    if N == 1:
        s, c = map(int, input().split())
        return c

    for i in range(M):
        s, c = map(int, input().split())
        if (s in d and d[s] != c) or (s == 1 and c == 0):
            return -1
        else:
            d[s] = c
    
    ans = [0] * N
    for key, val in d.items():
        ans[key - 1] = val
    if ans[0] == 0:
        ans[0] = 1
    ans = [str(c) for c in ans]

    return "".join(ans)

print(solve())

Fixed submission:
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

Buggy python submission (verdict: Runtime Error):
def solve():
    N, M = map(int, input().split())
        
    d = {}
    for i in range(M):
        s, c = map(int, input().split())
        if (s in d and d[s] != c) or (s == 1 and c == 0):
            return -1
        else:
            d[s] = c
    
    ans = [0] * N
    for key, val in d.items():
        ans[key - 1] = val

    if ans[0] == 0:
        ans[0] = 1
    ans = [str(c) for c in ans]

    return "".join(ans[i:])

print(solve())

Fixed submission:
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
s = []
c = []
num = ""

def judge():
    for i in range(M):
        s1, c1 = map(int, input().split())
        s.append(s1)
        c.append(c1)

    for i in range(M):
        for j in range(M):
            if s[i] == s[j] and i != j and c[i] != c[j]:
                print(-1)
                return

    if N == 3:        
        for i in range(M):
            if s[i] - 1 < 0 or s[i] - 1 > 2:
                print(-1)
                return
    elif N == 2:
        for i in range(M):
            if s[i] - 1 < 0 or s[i] - 1 > 1:
                print(-1)
                return
    else:
        if s[i] != 1:
                print(-1)
                return

    for i in range(M):
        num[s[i] - 1] = c[i]


    if num[0] == 0:
        if num[1] == 0:
            if num[2] == 0:
                print(-1)
                return
            print(num[2])
        print("{0}{1}".format(num[1], num[2]))
        return
    else:
        print("{0}{1}{2}".format(num[0], num[1], num[2]))
        return

judge()


Fixed submission:
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
s = []
c = []
num = [0] * N

def judge():
    for i in range(M):
        s1, c1 = map(int, input().split())
        s.append(s1)
        c.append(c1)

    for i in range(M):
        for j in range(M):
            if s[i] == s[j] and i != j and c[i] != c[j]:
                print(-1)
                return

    if N == 3:        
        for i in range(M):
            if s[i] - 1 < 0 or s[i] - 1 > 2:
                print(-1)
                return
            num[s[i] - 1] = c[i]
    elif N == 2:
        for i in range(M):
            if s[i] < 1 or s[i] > 2:
                print(-1)
                return
            num[s[i] - 1 + 1] = c[i]
    else:
        if s[i] != 2:
                print(-1)
                return
        num[s[i] - 1 + 2] = c[i] 



    if num[0] == 0:
        if num[1] == 0:
            if num[2] == 0:
                print(-1)
                return
            print(num[2])
        print("{0}{1}".format(num[1], num[2]))
        return
    else:
        print("{0}{1}{2}".format(num[0], num[1], num[2]))
        return

judge()


Fixed submission:
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
s = []
c = []
num = [0] * N

def judge():
    for i in range(M):
        s1, c1 = map(int, input().split())
        s.append(s1)
        c.append(c1)

    for i in range(M):
        for j in range(M):
            if s[i] == s[j] and i != j and c[i] != c[j]:
                print(-1)
                return

    if N == 3:        
        for i in range(M):
            if s[i] - 1 < 0 or s[i] - 1 > 2:
                print(-1)
                return
            num[s[i] - 1] = c[i]
    elif N == 2:
        for i in range(M):
            if s[i] < 0 or s[i] > 2:
                print(-1)
                return
            num[s[i] - 1 + 1] = c[i]
    else:
        if s[i] + 1 < 0 or s[i] + 1 > 2:
                print(-1)
                return
        num[s[i] - 1 + 2] = c[i] 



    if num[0] == 0:
        if num[1] == 0:
            if num[2] == 0:
                print(-1)
                return
            print(num[2])
        print("{0}{1}".format(num[1], num[2]))
        return
    else:
        print("{0}{1}{2}".format(num[0], num[1], num[2]))
        return

judge()


Fixed submission:
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
s = []
c = []
num = [0] * N

def judge():
    for i in range(M):
        s1, c1 = map(int, input().split())
        s.append(s1)
        c.append(c1)

    for i in range(M):
        for j in range(M):
            if s[i] == s[j] and i != j and c[i] != c[j]:
                print(-1)
                return

    if M == 3:        
        for i in range(M):
            if s[i] - 1 < 0 or s[i] - 1 > 2:
                print(-1)
                return
            num[s[i] - 1] = c[i]
    elif M == 2:
        for i in range(M):
            if s[i] < 0 or s[i] > 2:
                print(-1)
                return
            num[s[i] - 1 + 1] = c[i]
    else:
        if s[i] + 1 < 0 or s[i] + 1 > 2:
                print(-1)
                return
        num[s[i] - 1 + 2] = c[i] 



    if num[0] == 0:
        if num[1] == 0:
            if num[2] == 0:
                print(-1)
                return
            print(num[2])
        print("{0}{1}".format(num[1], num[2]))
        return
    else:
        print("{0}{1}{2}".format(num[0], num[1], num[2]))
        return

judge()


Fixed submission:
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
s = []
c = []
num = [0] * N

def judge():
    for i in range(M):
        s1, c1 = map(int, input().split())
        s.append(s1)
        c.append(c1)

    for i in range(M):
        for j in range(M):
            if s[i] == s[j] and i != j and c[i] != c[j]:
                print(-1)
                return
            
    for i in range(M):
        num[s[i] - 1] = c[i]
        
    if num[0] == 0:
        if num[1] == 0:
            if num[2] == 0:
                print(-1)
                return
            print(num[2])
        print("{0}{1}".format(num[1], num[2]))
        return
    else:
        print("{0}{1}{2}".format(num[0], num[1], num[2]))
        return

judge()


Fixed submission:
N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)