Buggy python submission (verdict: Runtime Error):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    SC = [il() for _ in range(M)]
    mi = pow(10, N - 1)-1
    mx = pow(10, N)

    for n in range(mi, mx):
        isSC = True
        for s, c in SC:
            if str(n)[s - 1] != str(c):
                isSC = False

        if isSC:
            print(n)
            exit()

    print(-1)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.readline().split()))
    lines = [line.rstrip() for line in sys.stdin.readlines()]

    ret = -1
    MIN = 0 if N == 1 else pow(10, N - 1)
    MAX = 10 if N == 1 else pow(10, N)
    for n in range(MIN, MAX):
        flg = True
        for line in lines:
            s, c = map(int, line.split())
            t = str(n)

            if t[s - 1] != str(c):
                flg = False

        if flg:
            ret = n
            break

    print(ret)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    SC = [il() for _ in range(M)]
    mi = pow(10, N-1)
    mx = pow(10, N)

    ret = float('inf')
    isRet = False
    for n in range(1, mx):
        isSC = True
        for sc in SC:
            s, c = sc
            if str(n)[s-1] != str(c):
                isSC = False

        if isSC:
            ret = min(ret, n)
            isRet = True

    print(ret if isRet else -1)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.readline().split()))
    lines = [line.rstrip() for line in sys.stdin.readlines()]

    ret = -1
    MIN = 0 if N == 1 else pow(10, N - 1)
    MAX = 10 if N == 1 else pow(10, N)
    for n in range(MIN, MAX):
        flg = True
        for line in lines:
            s, c = map(int, line.split())
            t = str(n)

            if t[s - 1] != str(c):
                flg = False

        if flg:
            ret = n
            break

    print(ret)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    SC = [il() for _ in range(M)]
    mi = pow(10, N-1)-1
    mx = pow(10, N)+1

    ret = float('inf')
    for n in range(mi, mx):
        isSC = True
        for sc in SC:
            s, c = sc
            if str(n)[s-1] != str(c):
                isSC = False

        if isSC:
            ret = min(ret, n)

    print(ret if ret < mx+1 else -1)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.readline().split()))
    lines = [line.rstrip() for line in sys.stdin.readlines()]

    ret = -1
    MIN = 0 if N == 1 else pow(10, N - 1)
    MAX = 10 if N == 1 else pow(10, N)
    for n in range(MIN, MAX):
        flg = True
        for line in lines:
            s, c = map(int, line.split())
            t = str(n)

            if t[s - 1] != str(c):
                flg = False

        if flg:
            ret = n
            break

    print(ret)


if __name__ == '__main__':
    main()