#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < (int)(m); i++) cin >> s[i] >> c[i], --s[i];
  string ans = "-1";
  for (int i = 0; i < (int)(1000); i++) {
    string si = to_string(i);
    if ((int)si.size() != n) continue;
    bool flag = false;
    for (int j = 0; j < (int)(m); j++) {
      if (si[s[j]] != (char)(c[j] + '0')) {
        flag = false;
        break;
      } else {
        flag = true;
      }
    }
    if (flag) {
      ans = si;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
