#!/usr/bin/env python3

import sys
import math
import itertools

def main():
    n, m = map(int, sys.stdin.readline().split())
    ss, cs = map(list, zip(*(map(int, sys.stdin.readline().split()) for _ in range(m))))

    ans = [None for _ in range(n)]

    for i in range(m):
        if ans[ss[i] - 1] is not None and ans[ss[i] - 1] != cs[i]:
            print(-1)
            return
        ans[ss[i] - 1] = cs[i]

    for k in range(n):
        if ans[k] == 0 and n > 1:
            print(-1)
            return
        elif ans[k] is not None:
            break

    for k in range(n):
        if ans[k] is None:
            if k == 0 and n > 1:
                ans[k] = 1
            else:
                ans[k] = 0

    print(''.join(map(str, ans)))


if __name__ == '__main__':
    main()