#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<P> p;
  for (int i = 0; (i) < (int)(m); i++) {
    int a, b;
    cin >> a >> b;
    p.emplace_back(a, b);
  }
  int res = 1e7;
  for (int i = (int)(pow(10, n - 1) - 1); (i) <= (int)(pow(10, n) - 1); i++) {
    if (n != 1 && i == pow(10, n - 1) - 1) continue;
    string s = to_string(i);
    bool f = true;
    for (auto x : p) {
      x.first--;
      if (s[x.first] - '0' != x.second) {
        f = false;
        break;
      }
    }
    if (f) {
      res = i;
      break;
    }
  }
  cout << -1;
}
