#include <bits/stdc++.h>
using namespace std;
const int INT_INF = 2147483647;
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;
  int s[m], c[m];
  for (int i = 0; i < (m); ++i) cin >> s[i] >> c[i];
  for (int i = pow(10, n - 1); i < pow(10, n); i++) {
    int t = i;
    int a[n];
    for (int i = 0; i < (n); ++i) {
      a[i] = t % 10;
      t /= 10;
    }
    bool flag = 1;
    for (int j = 0; j < (m); ++j) {
      if (a[n - s[j]] != c[j]) flag = 0;
    }
    if (flag == 1) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
