#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  char s[3] = {'~', '~', '~'};
  if (m == 0) {
    if (n > 1)
      cout << "-1" << endl;
    else
      cout << "0" << endl;
  }
  for (int i = 0; i < m; i++) {
    int n1;
    char m1;
    cin >> n1 >> m1;
    n1--;
    if (n1 == 0 && m1 == '0') {
      cout << "-1" << endl;
      return 0;
    }
    if (s[n1] == '~')
      s[n1] = m1;
    else if (s[n1] != m1) {
      cout << "-1" << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == 0 && n > 1) s[i] = '1';
    if (s[i] == '~') s[i] = '0';
  }
  if (s[0] == '0' && n > 1)
    cout << "-1" << endl;
  else
    for (int i = 0; i < n; i++) cout << s[i];
  cout << "\n";
  return 0;
}
