#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
bool compare(const pair<string, int> &a, const pair<string, int> &b) {
  return a.second < b.second;
}
int main() {
  int n, m, s, c, a;
  cin >> n >> m;
  vector<int> arr(n, -1);
  bool flag = true;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (arr[s - 1] == -1 || arr[s - 1] == c)
      arr[s - 1] = c;
    else {
      flag = false;
    }
  }
  if (arr[0] == -1 && (arr[1] == -1 || arr[1] == 0)) arr[0] = 1, arr[1] = 0;
  for (int i = 0; i < n; i++)
    if (arr[i] == -1) arr[i] = 0;
  if (flag) {
    if (n > 1 && !arr[0] && !arr[1])
      cout << -1 << "\n";
    else {
      for (int i = 0; i < n; i++) cout << arr[i];
      cout << "\n";
    }
  } else {
    cout << -1 << "\n";
  }
}
