def main():
    N,M=map(int, input().split())
    a = [-1] * N
    
    for _ in range(M):
        s,c=map(int, input().split())
        if a[s-1] == -1 or a[s-1] == c:
            a[s-1] = c
        else:
            print(-1)
            return
    
    if N > 1 and a[0] == 0:
        print(-1)
        return

    ans = ''
    for i in range(N):
        if a[i] != -1:
            ans += str(a[i])
        elif i == 0:
            ans += '1'
        else:
            ans += '0'
    print(ans)

if __name__ == '__main__':
    main()