#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  string s;
  for (int i = 0; i < n; i++) s.push_back('x');
  bool valid = true;
  for (int i = 0; i < m; i++) {
    int l;
    char k;
    cin >> l >> k;
    if (l == 1 && k == '0') {
      if (n != 1)
        valid = false;
      else
        s[l - 1] = k;
    } else if (s[l - 1] == k)
      s[l - 1] = k;
    else if (s[l - 1] != 'x' && s[l - 1] != k)
      valid = false;
    else
      s[l - 1] = k;
  }
  if (!valid)
    cout << "-1" << '\n';
  else {
    for (int i = 1; i < n; i++)
      if (s[i] == 'x') s[i] = '0';
    if (s[0] == 'x') s[0] = '1';
    cout << s << "\n";
  }
  return 0;
}
