#!/usr/bin/env python

def func():
    n,m = [int(i) for i in input().split(" ")]
    dic = {}
    same = 0
    for i in range(m):
        tmp = [int(i) for i in input().split(" ")]

        if tmp[0] not in dic.keys():
            dic[tmp[0]] = tmp[1]
        else:
            if dic[tmp[0]] != tmp[1]:
                print("No")
                return
            else:
                same += 1
    a = [0] * (m-same)
    for key in dic.keys():
        print(key)
        a[key-1] = dic[key]

    if a[0] == 0:
        print("No")
        return

    for i in a:
        print(i, end = "")

    print("")

if __name__ == "__main__":
    func()