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