
def main():
    N, M = tuple(map(int, input().split()))

    digits = {}
    for i in range(M):
        s, c = tuple(map(int, input().split()))
        digits[s] = c

    num = 0

    for s, c in digits.items():
        num += 10 ** (s - 1) * c

    if (1 not in digits.keys()) or digits[1] == 0:
        print(-1)
        return

    num = int(str(num)[::-1])

    length = len(str(num))

    if length >= N:
        print(num)
    else:
        print(-1)

if __name__ == "__main__":
    main()
