#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  pair<int, int> sc[M];
  int s, c;
  for (int i = 0; i < M; i++) {
    cin >> s >> c;
    sc[i] = pair<int, int>(s, c);
  }
  for (int i = pow(10, N - 1); i < pow(10, N); i++) {
    bool success = true;
    string s = to_string(i);
    for (pair<int, int> p : sc) {
      if (stoi(string() + s.at(p.first - 1)) != p.second) {
        success = false;
        break;
      }
    }
    if (success) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}
