#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmin(T& a, T b, bool f) {
  if (f == 1) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
  } else if (f == 0) {
    if (a < b) {
      a = b;
      return true;
    }
    return false;
  }
  return false;
}
const int inf = 2147483647;
const ll INF = 9223372036854775807;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > a(m);
  for (int i = 0; i < m; i++) cin >> a[i].first >> a[i].second;
  int ans = -1;
  for (int i = 1; i < pow(10, n); i++) {
    bool flag = true;
    string s = to_string(i);
    if (s.size() != n) continue;
    for (int j = 0; j < m; j++) {
      if (s[a[j].first - 1] - '0' != a[j].second) flag = false;
    }
    if (flag) {
      cout << i << "\n";
      return 0;
    }
  }
  cout << -1 << "\n";
  return 0;
}
