If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`.

* The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.)
* The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)

Constraints

* All values in input are integers.
* 1 \leq N \leq 3
* 0 \leq M \leq 5
* 1 \leq s_i \leq N
* 0 \leq c_i \leq 9

Input

Input is given from Standard Input in the following format:


N M
s_1 c_1
\vdots
s_M c_M


Output

Print the answer.

Examples

Input

3 3
1 7
3 2
1 7


Output

702


Input

3 2
2 1
2 3


Output

-1


Input

3 1
1 0


Output

-1
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] Ss = new int[M];
        int[] Cs = new int[M];
        for (int m = 0; m < M; m++){
            Ss[m] = sc.nextInt();
            Cs[m] = sc.nextInt();
        }

        int[] text = new int[N];
        int noFlg = 0;
        for (int m = 0; m < M; m++){
            if (((Ss[m]-1) == 0) && (Cs[m] == 0) && (N>1)) {
                noFlg = 1;
                break;
            }
            if ((text[Ss[m]-1] != 0) && (text[Ss[m]-1] != Cs[m])) {
                noFlg = 1;
                break;
            }
            text[Ss[m]-1] = Cs[m];
        }
        StringBuilder sb = new StringBuilder();
        for (int t: text) {
            sb.append(String.valueOf(t));
        }
        String ans_text = sb.toString();
        if ((ans_text.length() > 1) && (ans_text.charAt(0) == '0')) {
            ans_text = ans_text.replaceFirst("0","1");
        }
        if (noFlg == 1) System.out.println("-1");
        else System.out.println(ans_text);
    }
}
