def q3():
    N,M = (int(i) for i in input().split())
    ans = ['0']*N
    for m in range(M):
        s, c = (i for i in input().split())
        ans[int(s)-1] = c

    ans = ''.join(ans)
    if len(str(int(ans))) == len(ans):
        print(ans)
    else:
        print(-1)

if __name__ == '__main__':
    q3()