#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  int m_arr[6] = {-1, -1, -1, -1, -1, -1};
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0) {
      cout << "-1" << endl;
      return 0;
    }
    if (m_arr[s] == -1)
      m_arr[s] = c;
    else if (c != m_arr[s]) {
      cout << "-1" << endl;
      return 0;
    }
  }
  string str;
  for (int i = 0; i < n; i++) {
    if (m_arr[i + 1] == -1) {
      if (i == 0)
        str += '1';
      else
        str += '0';
    } else {
      str += to_string(m_arr[i + 1]);
    }
  }
  cout << str << endl;
  return 0;
}
