#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, l, n, m;
  string second;
  cin >> n >> m;
  for (i = 0; i < n; i++) second += 'a';
  for (i = 0; i < m; i++) {
    cin >> j >> k;
    if (second[j - 1] == 'a')
      second[j - 1] = k + '0';
    else if (second[j - 1] == k + '0')
      ;
    else {
      cout << "-1\n";
      return 0;
    }
  }
  for (i = 0; i < n; i++)
    if (second[i] == 'a')
      if (i == 0 && n != 1)
        second[i] = 1 + '0';
      else
        second[i] = '0';
  if (second[0] == '0') {
    cout << "-1\n";
    return 0;
  }
  cout << second << endl;
  return 0;
}
