#include <bits/stdc++.h>
using namespace std;
void solve(int N, int M, vector<int> s, vector<int> c) {
  auto thisIsIt = [&](const int X) {
    string Xstr = to_string(X);
    for (int i = 0; i < M; ++i)
      if (Xstr[s[i] - 1] - '0' != c[i]) {
        return false;
      }
    return true;
  };
  for (int X = pow(10, (N - 1)); X < pow(10, N); ++X)
    if (thisIsIt(X)) {
      cout << X << endl;
      return;
    }
  cout << -1 << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  for (int i = 0; i < M; ++i) cin >> s[i] >> c[i];
  solve(N, M, move(s), move(c));
  return 0;
}
