#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;
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]--;
  }
  int ans = 0;
  for (int n = 0; n < (int)pow(10, N); n++) {
    string sn = to_string(n);
    bool ok = true;
    for (int i = 0; i < M; i++) {
      if (sn[s[i]] - '0' != c[i]) {
        ok = false;
      }
    }
    if (ok) {
      cout << sn << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}
