#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> prime_factorize(long long n) {
  vector<pair<long long, long long>> res;
  for (long long p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<long long unsigned int, long long unsigned int>> vec;
  bool flag = false;
  for (int i = 0; i < (m); i++) {
    int s, c;
    cin >> s >> c;
    if (s == 1 && c != 0) {
      flag = true;
    }
    vec.push_back(make_pair(s, c));
  }
  string s;
  for (int i = 0; i < n; i++) {
    s += '0';
  }
  for (int i = 0; i < (m); i++) {
    s[vec[i].first - 1] = vec[i].second + '0';
  }
  if (!flag) {
    cout << -1 << endl;
    return 0;
  }
  cout << s << endl;
  return 0;
}
