def main():
    n, m = map(int, input().split())
    
    ans = []
    for i in range(n):
        ans.append('0')

    for j in range(m):
        s, c = input().split()
        ans[int(s)-1] = c
    
    tmp = int("".join(ans))

    if tmp // 10**(n-1) > 0:
        print(tmp)
    else:
        print(-1)


if __name__ == '__main__':
    main()
