#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (long long(i) = 0; (i) < (m); (i)++) {
    cin >> s[i] >> c[i];
  }
  string ans = "";
  for (long long(i) = 0; (i) < (1000); (i)++) {
    bool ok = true;
    ans = to_string(i);
    if (i / 10 + 1 != n) continue;
    for (long long(i) = 0; (i) < (m); (i)++) {
      if (s[i] > ans.length()) {
        ok = false;
        break;
      }
      if (ans[s[i] - 1] - '0' != c[i]) ok = false;
    }
    if (ok) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
