Problem p02761 (python)

Fixed submission:
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
NUM = 0
LIST = [-1 for _ in range(N)]
for s,c in S:
    s -= 1
    if(LIST[s]==-1):
        NUM += c*(10**(N-s-1))
        LIST[s] = c
    else:
        if(LIST[s]!=c):
            flag = 1
            print(-1)
            break
        else:
            continue
if(LIST[0] == -1):
    if(N>1):
        NUM += 10**(N-1)
    else:
        NUM = 0
elif(LIST[0] == 0):
    if(N>1):
        print(-1)
        flag = 1
    else:
        NUM = 0
if(flag==0):
    print(NUM)

Buggy submission (verdict: Runtime Error):
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
NUM = 0
LIST = [-1 for _ in range(N)]
for s,c in S:
  s -= 1
  if(LIST[s]==-1):
    NUM += c*(10**(N-s-1))
    LIST[s] = c
    else:
      if(LIST[s]!=c):
        flag = 1
        print(-1)
        break
        else:
          continue
          if(LIST[0] == -1):
            if(N>1):
              NUM += 10**(N-1)
              else:
                NUM = 0
                elif(LIST[0] == 0):
                  if(N>1):
                    print(-1)
                    flag = 1
                    else:
                      NUM = 0
                      if(flag==0):
                        print(NUM)

Buggy submission (verdict: Runtime Error):
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
else:
    NUM = 0
    LIST = [-1 for _ in range(N)]
    for s,c in S:
        s -= 1
        if(LIST[s]==-1):
            NUM += c*(10**(N-s-1))
            LIST[s] = c
        else:
            if(LIST[s]!=c):
                flag = 1
                print(-1)
                break
            else:
                continue
    if(LIST[0] == -1):
        if(N>1):
            NUM += 10**(N-1)
        else:
            NUM = 0
    elif(LIST[0] == 0):
        if(N>1):
            print(-1)
            flag = 1
        else:
            NUM = 0
    if(flag==0):
        print(NUM)

Buggy submission (verdict: Runtime Error):
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
else:
    NUM = 0
    LIST = [-1 for _ in range(N)]
    for s,c in S:
        s -= 1
        if(LIST[s]==-1):
            NUM += c*(10**(N-s-1))
            LIST[s] = c
        else:
            if(LIST[s]!=c):
                flag = 1
                print(-1)
                break
            else:
                continue
    if(LIST[0] == -1):
        if(N>1):
            NUM += 10**(N-1)
        else:
            NUM = 0
    elif(LIST[0] == 0):
        if(N>1):
            print(-1)
            flag = 1
        else:
            NUM = 0
    if(flag==0):
        print(NUM)

Buggy submission (verdict: Runtime Error):
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
if([1,0] in S):
    flag = 1
    print(-1)
else:
    NUM = 0
    LIST = [-1 for _ in range(M)]
    for s,c in S:
        s -= 1
        if(LIST[s]==-1):
            NUM += c*(10**(N-s-1))
            LIST[s] = c
        else:
            if(LIST[s]!=c):
                flag = 1
                print(-1)
                break
            else:
                continue
    if(LIST[0] == -1):
        if(N>1):
            NUM += 10**(N-1)
        else:
            NUM = 0
    if(flag==0):
        print(NUM)

Buggy submission (verdict: Runtime Error):
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
if([1,0] in S):
    flag = 1
    print(-1)
else:
    NUM = 0
    LIST = [-1 for _ in range(M)]
    for s,c in S:
        s -= 1
        if(LIST[s]==-1):
            NUM += c*(10**(N-s-1))
            LIST[s] = c
        else:
            if(LIST[s]!=c):
                flag = 1
                print(-1)
                break
            else:
                continue
    if(LIST[0] == -1):
        if(N>2):
            NUM += 10**(N-1)
        else:
            NUM = 0
    if(flag==0):
        print(NUM)

Buggy submission (verdict: Runtime Error):
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
if([1,0] in S):
    flag = 1
    print(-1)
else:
    NUM = 0
    LIST = [-1 for _ in range(M)]
    for s,c in S:
        s -= 1
        if(LIST[s]==-1):
            NUM += c*(10**(N-s-1))
            LIST[s] = c
        else:
            if(LIST[s]!=c):
                flag = 1
                print(-1)
                break
            else:
                continue
    if(LIST[0] == -1):
        if(N>2):
            NUM += 10**(N-1)
        else:
            NUM = 0
    if(flag==0):
        print(NUM)

Buggy submission (verdict: Runtime Error):
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
if([1,0] in S):
    flag = 1
    print(-1)
else:
    NUM = 0
    LIST = [-1 for _ in range(M)]
    for s,c in S:
        s -= 1
        if(LIST[s]==-1):
            NUM += c*(10**(N-s-1))
            LIST[s] = c
        else:
            if(LIST[s]!=c):
                flag = 1
                print(-1)
                break
            else:
                continue
    if(LIST[0] == -1):
        if(N>2):
            NUM += 10**(N-1)
        else:
            NJM = 0
    if(flag==0):
        print(NUM)

Buggy submission (verdict: Runtime Error):
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
if([1,0] in S):
    flag = 1
    print(-1)
else:
    NUM = 0
    LIST = [-1 for _ in range(M)]
    for s,c in S:
        s -= 1
        if(LIST[s]==-1):
            NUM += c*(10**(N-s-1))
            LIST[s] = c
        else:
            if(LIST[s]!=c):
                flag = 1
                print(-1)
                break
            else:
                continue
    if(LIST[0] == -1):
        NUM += 10**(N-1)
    if(flag==0):
        print(NUM)

Buggy submission (verdict: Runtime Error):
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
if([1,0] in S):
  flag = 1
  print(-1)
else:
  NUM = 0
  LIST = [-1 for _ in range(M)]
  for s,c in S:
    s -= 1
    if(LIST[s]==-1):
      NUM += c*(10**(N-s-1))
      LIST[s] = c
    else:
      if(LIST[s]!=c):
        flag = 1
        print(-1)
        break
      else:
        continue
  if(LIST[0] == -1):
    NUM += 10**(N-1)
  if(flag==0):
    print(NUM)

Buggy submission (verdict: Runtime Error):
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
if([1,0] in S):
  print(-1)
else:
  NUM = 0
  LIST = [-1 for _ in range(M)]
  for s,c in S:
    s -= 1
    if(LIST[s]==-1):
      NUM += c*(10**(N-s-1))
      LIST[s] = c
    else:
      if(LIST[s]!=c):
        print(-1)
        break
      else:
        continue
  if(LIST[0] == -1):
    NUM += 10**(N-1)
  print(NUM)