#include <bits/stdc++.h>
using namespace std;
const long long LINF = LLONG_MAX;
const int INF = INT_MAX;
const int MOD = 998244353;
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
  for (int i = pow(10, n - 1); i < pow(10, n); i++) {
    string x = to_string(i);
    bool ok = true;
    for (int j = 0; j < m; j++) {
      if (x[s[j] - 1] != '0' + c[j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << x;
      return 0;
    }
  }
  cout << "-1";
}
