def main():
    N, M = map(int, input().split())
    digits = ["empty"] * N

    for _ in range(M):
        s, c = map(int, input().split())
        if digits[s-1] != "empty" and digits[s-1] != str(c):
            print(-1)
            return

        digits[s-1] = str(c)

    if digits[0] == str(0):
        print(-1)
        return
    elif digits[0] == "empty":
        digits[0] = "1"

    print("".join(digits).replace("empty", "0"))


if __name__ == "__main__":
    main()
