#include <bits/stdc++.h>
using namespace std;
const double h = 1e-6;
const int MAX_ = 100005;
inline long long int mul(long long int a, long long int b) {
  return (a * 1ll * b) % 1000000007;
}
inline long long int sub(long long int a, long long int b) {
  long long int c = a - b;
  if (c < 0) c += 1000000007;
  return c;
}
inline long long int add(long long int a, long long int b) {
  long long int c = a + b;
  if (c > 1000000007) c -= 1000000007;
  return c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > v;
  for (long long int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v.push_back({a, b});
  }
  int st = pow(10, n - 1);
  int ed = pow(10, n) - 1;
  for (int val = st; val <= ed; val++) {
    string s = to_string(val);
    int f = 1;
    for (int j = 0; j < v.size(); j++) {
      int a = v[j].first;
      int b = v[j].second;
      char bb = b + '0';
      if (s[a - 1] != bb) {
        f = 0;
        break;
      }
    }
    if (f == 1) {
      cout << s;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
