#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int sz = 500;
int main() {
  int n, m;
  cin >> n >> m;
  int x, y;
  string str = "";
  str.append(n, 'a');
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (str[x - 1] == 'a')
      str[x - 1] = (y + '0');
    else if (str[x - 1] != (y + '0')) {
      str[0] = 'b';
    }
  }
  for (int i = 0; i < str.size(); i++)
    if (str[i] == 'a') str[i] = '0';
  if (str[0] == '0' || str[0] == 'b')
    puts("-1");
  else
    cout << str << endl;
  return 0;
}
