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