#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
lint digit(lint);
int main() {
  lint n, m;
  cin >> n >> m;
  vector<pair<lint, lint> > d(m);
  for (int i = 0; i < m; ++i) {
    cin >> d[i].first >> d[i].second;
  }
  sort(d.begin(), d.end());
  lint ans = 0;
  if (d[0].first != 1) ans = pow(10, n);
  int i = 0;
  for (int j = 1; j <= 9; ++j) {
    if (j > n) {
      ans = -1;
      break;
    }
    if (d[i].first == j) {
      ans += d[i].second * pow(10, n - j);
      do {
        ++i;
      } while (d[i].first == d[i - 1].first);
    }
  }
  cout << ans << endl;
}
lint digit(lint num) {
  lint dig = 0;
  while (num) {
    num /= 10;
    ++dig;
  }
  return dig;
}
