#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int c[m][2];
  for (int i = 0; i < m; i++) cin >> c[i][0] >> c[i][1];
  int start = pow(10, n - 1);
  int end = start * 10;
  if (n == 1) start = 0;
  for (int i = start; i < end; i++) {
    string s = "";
    int j = i;
    while (j != 0) {
      char c = '0' + j % 10;
      s = c + s;
      j = j / 10;
    }
    int check = 1;
    for (int k = 0; k < m; k++) {
      if (s[c[k][0] - 1] != c[k][1] + '0') check = 0;
    }
    if (check == 1) {
      cout << s;
      return 0;
    }
  }
  cout << "-1\n";
}
