import sys
def main(lines):
    a = []
    for i,v in enumerate(lines):
        if i == 0:
            k = v.split(' ')
            n = int(k[0])
            m = int(k[1])
        else:
            ju = [int(a) for a in v.split(' ')]
            if not ju in a:
                a.append(ju)

    d = 0
    f = 0
    flg = [0 for _ in range(n)]
    for i in a:
        d += i[1]*(10**(m-i[0]))
        if flg[i[0]-1] == 1:
            f = 1
        flg[i[0]-1] = 1

    if f == 1 or d < 100:
        print(-1)
    else:
        print(d)

if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)