#include <bits/stdc++.h>
using namespace std;
using P = pair<long, long>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> v;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    v.push_back({s, c});
  }
  int upper = pow(10, n);
  int ans = 0;
  int i;
  if (n == 1) {
    i = 0;
  } else {
    i = upper / 10;
  }
  for (i = upper / 10; i < upper; i++) {
    string s = to_string(i);
    int flag = 1;
    for (int j = 0; j < m; j++) {
      if (s[v[j].first - 1] - '0' != v[j].second) flag = 0;
    }
    if (flag) {
      ans = i;
      break;
    }
  }
  if (ans == 0)
    cout << -1 << endl;
  else
    cout << ans << endl;
}
