#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string ans(n, '0');
  if (ans.size() != 1) ans.at(0) = '1';
  bool ok = true;
  for (int i = 0; i < m; i++) {
    int s;
    cin >> s;
    char c;
    cin >> c;
    if (s == 1 && ans.at(s - 1) != '1') ok = false;
    if (s != 1 && ans.at(s - 1) != '0') ok = false;
    ans.at(s - 1) = c;
  }
  if (ok && ans.at(0) != '0')
    cout << ans << endl;
  else if (n == 1)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
