Buggy python submission (verdict: Runtime Error):
def resolve():
    def main():
        N, M = map(int, input().split())
        S, C = [0] * M, [0] * M

        if N == 1 and M == 1:
            return 0
        elif N == 2 and M == 0:
            return 10
        elif N == 3 and M == 0:
            return 100

        for i in range(M):
            S[i], C[i] = map(int, input().split())
            if i == 0:
                dic = {S[i]: C[i]}
            else:
                if S[i] not in dic.keys():
                    dic[S[i]] = C[i]
                elif dic[S[i]] != C[i]:
                    return -1

        ans = [0] * N
        for i, j in dic.items():
            ans[i - 1] = j

        if len(ans) != 1 and ans[0] == 0:
            return -1
        else:
            return ans

    val = main()
    try:
        int(val)
        print(val)
    except:
        for i in val:
            print(i, end='')
        print()


resolve()

Fixed submission:
N,M=map(int,input().split())
s=[list(map(int,input().split())) for i in range(M)]

#print(A)
def main():
    if N==1 and M==0:
        return 0
    if N==2 and M==0:
        return 10
    if N==3 and M==0:
        return 100

        
    if N==1:
        for i in range(0,10**N):
            for j in range(M):
                if str(i)[s[j][0]-1]!=str(s[j][1]):
                    break
                if j==M-1:
                    return i
            if i==10**N-1:
                return -1
    else:
        for i in range(10**(N-1),10**N):
            for j in range(M):
                if str(i)[s[j][0]-1]!=str(s[j][1]):
                    break
                if j==M-1:
                    return i
            if i==10**N-1:
                return -1
                    

print(main())

Buggy python submission (verdict: Runtime Error):
def resolve():
    def main():
        N,M=map(int,input().split())
        S, C = [0] * M, [0] * M

        for i in range(M):
            S[i], C[i] = map(int, input().split())
            if i==0:
                dic={S[i]:C[i]}
            else:
                if S[i] not in dic.keys():
                    dic[S[i]]=C[i]
                elif dic[S[i]]!=C[i]:
                    return -1
        #dic=dict(sorted(dic.items(), key=lambda x: x[0]))
        ans=[0]*N
        for i,j in dic.items():
            ans[i-1]=j

        if len(ans)!=1 and ans[0]==0:
            return -1
        else:
            return ans

    val=main()
    if val==-1:
        print(-1)
    else:
        for i in val:
            print(i,end='')
        print()







resolve()

Fixed submission:
N,M=map(int,input().split())
s=[list(map(int,input().split())) for i in range(M)]

#print(A)
def main():
    if N==1 and M==0:
        return 0
    if N==2 and M==0:
        return 10
    if N==3 and M==0:
        return 100

        
    if N==1:
        for i in range(0,10**N):
            for j in range(M):
                if str(i)[s[j][0]-1]!=str(s[j][1]):
                    break
                if j==M-1:
                    return i
            if i==10**N-1:
                return -1
    else:
        for i in range(10**(N-1),10**N):
            for j in range(M):
                if str(i)[s[j][0]-1]!=str(s[j][1]):
                    break
                if j==M-1:
                    return i
            if i==10**N-1:
                return -1
                    

print(main())