#include <bits/stdc++.h>
using namespace std;
int main() {
  ostringstream oss;
  int n, m, a = 1, b, x, y, sum = 0;
  int flag = 0;
  char c;
  string s;
  cin >> n >> m;
  if (n == 1 && m == 0) {
    cout << "0" << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; ++i) a *= 10;
  oss << a;
  s = oss.str();
  cout << a << endl;
  cout << s << endl;
  for (int i = 0; i < m; ++i) {
    cin >> x >> c;
    if (x == 1 && c == '0' && n != 1 || n < x) {
      flag = 1;
      break;
    }
    if (s[x - 1] == '0' || s[x - 1] == c) {
      s[x - 1] = c;
    } else if (x == 1 && s[x - 1] == '1') {
      s[x - 1] = c;
    } else {
      flag = 1;
      break;
    }
  }
  if (!flag) cout << s << endl;
  if (flag) cout << "-1" << endl;
  return 0;
}
