#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct edge {
  int to, cost;
};
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
const int mx4[] = {0, 1, 0, -1};
const int my4[] = {1, 0, -1, 0};
const int mx8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int my8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int pw(int x) {
  int ret = 1;
  for (int i = 0; i < (int)(x); i++) ret *= 10;
  return ret;
}
int main() {
  int n, m;
  cin >> n >> m;
  int s[10], c[10];
  for (int i = 0; i < (int)(m); i++) cin >> s[i] >> c[i];
  for (int i = pw(n - 1); i < pw(n); i++) {
    int flag = 1;
    for (int j = 0; j < m; j++) {
      int a = (int)(i / pow(10, n - s[j])) % 10;
      if (c[j] != a) flag = 0;
    }
    if (flag) {
      cout << i << "\n";
      return 0;
    }
  }
  cout << -1 << "\n";
  return 0;
}
