#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
int m;
vector<int32_t> s, c;
bool ok(string& x) {
  bool ret = true;
  for (int i = 0; i < m; ++i) {
    if (x[s[i] - 1] != c[i] + '0') ret = false;
  }
  return ret;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n >> m;
  s.resize(m);
  c.resize(m);
  for (int i = 0; i < m; ++i) {
    cin >> s[i] >> c[i];
  }
  string ans(n, '0');
  ans[0] = '1';
  int lim = 1;
  for (int i = 0; i < n; ++i) lim *= 10;
  int temp;
  while (!ok(ans)) {
    temp = stoi(ans);
    ++temp;
    if (temp >= lim) break;
    for (int idx = n - 1; idx >= 0; --idx) {
      ans[idx] = '0' + temp % 10;
      temp /= 10;
    }
  }
  if (temp >= lim) ans = "-1";
  cout << ans << "\n";
  return 0;
}
