#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int s[m];
  char c[m];
  if (m == 0) {
    if (n == 1) {
      cout << "0";
      return 0;
    } else {
      cout << pow(10, n - 1);
      return 0;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
  }
  for (int i = 0; i < m; i++) {
    if ((s[i] == 1) && (c[i] == '0')) {
      if (n == 0) {
        cout << "0";
        return 0;
      } else {
        cout << "-1";
        return 0;
      }
    }
  }
  int ans = -1;
  for (int i = pow(10, n - 1); i < pow(10, n); i++) {
    string st = to_string(i);
    for (int j = 0; j < m; j++) {
      if (!(st[s[j] - 1] == c[j])) {
        break;
      }
      if (j == m - 1) ans = i;
    }
    if (!(ans == -1)) break;
  }
  cout << ans;
}
