#include <bits/stdc++.h>
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, ans = 0;
  cin >> n >> m;
  vector<pair<int, char>> vs(m);
  map<int, char> make_pair;
  for (int i = 0; i < m; ++i) {
    cin >> vs[i].first >> vs[i].second;
    auto it = make_pair.find(vs[i].first);
    if (it == make_pair.end()) {
      make_pair[vs[i].first] = vs[i].second;
    } else if (make_pair[vs[i].first] != vs[i].second) {
      ans = 1;
    }
  }
  auto it = make_pair.find(1);
  if (it != make_pair.end() && make_pair[1] == '0' && n > 1) ans = 1;
  if (ans) {
    cout << -1 << endl;
    exit(0);
  }
  string res;
  for (int i = 0; i < n; ++i) {
    auto it = make_pair.find(i + 1);
    if (it != make_pair.end()) {
      res.push_back(make_pair[i + 1]);
    } else if (i > 0) {
      res.push_back('0');
    } else
      res.push_back('1');
  }
  cout << res << endl;
  return 0;
}
