n,m=map(int, input().split())
box = ["0" for i in range(n)]
for i in range(m):
    s = int(input())
    c = str(input())
    box[s-1] = c
    
if n > 1 and box[0] == '0':
    print(-1)
    
else:
    for x in box:
        ans += x
    print(x)
    
    
    
