#include <bits/stdc++.h>
using namespace std;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
int main() {
  int n, m, s;
  char c;
  cin >> n >> m;
  vector<vector<char>> jouken(5, vector<char>());
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (s == 1 && c == '0') {
      cout << -1 << endl;
      return 0;
    }
    if (s > n) {
      cout << -1 << endl;
      ;
      return 0;
    }
    if (jouken.at(s - 1).size() > 0 && jouken.at(s - 1).at(0) != c) {
      cout << -1 << endl;
      return 0;
    }
    jouken.at(s - 1).push_back(c);
  }
  string ans;
  for (int i = 0; i < n; i++) {
    if (jouken.at(i).size() == 0) {
      if (i == 0)
        ans.push_back('1');
      else
        ans.push_back('0');
    } else {
      char c = jouken.at(i).at(0);
      ans.push_back(c);
    }
  }
  cout << ans << endl;
}
