#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < (m); i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  for (int i = (pow(10, n - 1)); i < (pow(10, n)); i++) {
    bool flag = true;
    string S = to_string(i);
    for (int k = 0; k < (m); k++) {
      if ((S[s[k]] - '0') != c[k]) {
        flag = false;
      }
    }
    if (flag) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
}
