Buggy python submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    num = [set() for _ in range(n)]
    ans = ""
    for _ in range(m):
        s, v = input().split()
        num[int(s)-1].add(v)
    if n > 1 and list(num[0])[0] == "0":
        print(-1)
        return
    for i in num[:-1]:
        if len(i) == 0:
            ans += "0"
        elif len(i) == 1:
            ans += list(i)[0]
        else:
            print(-1)
            return
    if len(num[-1]) > 1:
        print(-1)
        return
    if len(num[-1]) == 1:
        ans += list(num[-1])[0]
    else:
        if m == 1:
            ans += "0"
        else:
            ans += "1"
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, m = map(int, input().split())
    ans = [None]*n
    for _ in range(m):
        s, c = map(int, input().split())
        try:
            if ans[s-1] is None:
                if c == 0 and s != n:
                    print("-1")
                    return
                ans[s-1] = c
            elif ans[s-1] != c:
                print("-1")
                return
        except:
            print("-1")
            return
    ans_str = ""
    p = ans.pop(0)
    if p is None:
        if n == 1:
            ans_str += "0"
        else:
            ans_str += "1"
    else:
        ans_str += str(p)
    if ans:
        for a in ans:
            ans_str += str(a) if a else "0"
    print(ans_str)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    num = [set() for _ in range(m)]
    ans = ""
    for _ in range(m):
        s, v = input().split()
        num[int(s)-1].add(v)
    if n > 1 and list(num[0])[0] == "0":
        print(-1)
        return
    for i in num[:-1]:
        if len(i) == 0:
            ans += "0"
        elif len(i) == 1:
            ans += list(i)[0]
        else:
            print(-1)
            return
    if len(num[-1]) > 1:
        print(-1)
        return
    if len(num[-1]) == 1:
        ans += list(num[-1])[0]
    else:
        if m == 1:
            ans += "0"
        else:
            ans += "1"
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, m = map(int, input().split())
    ans = [None]*n
    for _ in range(m):
        s, c = map(int, input().split())
        try:
            if ans[s-1] is None:
                if c == 0 and s != n:
                    print("-1")
                    return
                ans[s-1] = c
            elif ans[s-1] != c:
                print("-1")
                return
        except:
            print("-1")
            return
    ans_str = ""
    p = ans.pop(0)
    if p is None:
        if n == 1:
            ans_str += "0"
        else:
            ans_str += "1"
    else:
        ans_str += str(p)
    if ans:
        for a in ans:
            ans_str += str(a) if a else "0"
    print(ans_str)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    num = [set() for _ in range(m)]
    ans = ""
    for _ in range(m):
        s, v = input().split()
        num[int(s)-1].add(v)
    for i in num[:-1]:
        if len(i) == 0:
            ans += "0"
        elif len(i) == 1:
            ans += list(i)[0]
        else:
            print(-1)
            return
    if len(num[-1]) > 1:
        print(-1)
        return
    if len(num[-1]) == 1:
        ans += list(num[-1])[0]
    else:
        if n == 1:
            ans += "0"
        else:
            ans += "1"
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, m = map(int, input().split())
    ans = [None]*n
    for _ in range(m):
        s, c = map(int, input().split())
        try:
            if ans[s-1] is None:
                if c == 0 and s != n:
                    print("-1")
                    return
                ans[s-1] = c
            elif ans[s-1] != c:
                print("-1")
                return
        except:
            print("-1")
            return
    ans_str = ""
    p = ans.pop(0)
    if p is None:
        if n == 1:
            ans_str += "0"
        else:
            ans_str += "1"
    else:
        ans_str += str(p)
    if ans:
        for a in ans:
            ans_str += str(a) if a else "0"
    print(ans_str)


if __name__ == "__main__":
    main()