Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
import math
import itertools

def main():
    n, m = map(int, sys.stdin.readline().split())
    ss, cs = map(list, zip(*(map(int, sys.stdin.readline().split()) for _ in range(m))))

    ans = [None for _ in range(n)]

    for i in range(m):
        if ans[ss[i] - 1] is None:
            ans[ss[i] - 1] = cs[i]
        elif ans[ss[i] - 1] != cs[i]:
            return "-1"

    if n == 1:
        if ans[0] == None:
            return "0"
        else:
            return str(ans[0])

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

    for k in range(n):
        if ans[k] is None:
            if k == 0:
                ans[k] = 1
            else:
                ans[k] = 0

    return ''.join(map(str, ans))

if __name__ == '__main__':
    print(main())


Fixed submission:
#!/usr/bin/env python3

import sys
import math
import itertools

def main():
    n, m = map(int, sys.stdin.readline().split())
    if m == 0:
        ss = []
        cs = []
    else:
        ss, cs = map(list, zip(*(map(int, sys.stdin.readline().split()) for _ in range(m))))

    ans = [None for _ in range(n)]

    for i in range(m):
        if ans[ss[i] - 1] is None:
            ans[ss[i] - 1] = cs[i]
        elif ans[ss[i] - 1] != cs[i]:
            return "-1"

    if n == 1:
        if ans[0] is None:
            return "0"
        else:
            return str(ans[0])

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

    for k in range(n):
        if ans[k] is None:
            if k == 0:
                ans[k] = 1
            else:
                ans[k] = 0

    return ''.join(map(str, ans))

if __name__ == '__main__':
    print(main())

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
import math
import itertools

def main():
    n, m = map(int, sys.stdin.readline().split())
    ss, cs = map(list, zip(*(map(int, sys.stdin.readline().split()) for _ in range(m))))

    ans = [None for _ in range(n)]

    for i in range(m):
        if ans[ss[i] - 1] is not None and ans[ss[i] - 1] != cs[i]:
            print(-1)
            return
        ans[ss[i] - 1] = cs[i]

    for k in range(n):
        if ans[k] == 0 and n > 1:
            print(-1)
            return
        elif ans[k] is not None:
            break

    for k in range(n):
        if ans[k] is None:
            if k == 0 and n > 1:
                ans[k] = 1
            else:
                ans[k] = 0

    print(''.join(map(str, ans)))


if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python3

import sys
import math
import itertools

def main():
    n, m = map(int, sys.stdin.readline().split())
    if m == 0:
        ss = []
        cs = []
    else:
        ss, cs = map(list, zip(*(map(int, sys.stdin.readline().split()) for _ in range(m))))

    ans = [None for _ in range(n)]

    for i in range(m):
        if ans[ss[i] - 1] is None:
            ans[ss[i] - 1] = cs[i]
        elif ans[ss[i] - 1] != cs[i]:
            return "-1"

    if n == 1:
        if ans[0] is None:
            return "0"
        else:
            return str(ans[0])

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

    for k in range(n):
        if ans[k] is None:
            if k == 0:
                ans[k] = 1
            else:
                ans[k] = 0

    return ''.join(map(str, ans))

if __name__ == '__main__':
    print(main())