#include <bits/stdc++.h>
using namespace std;
bool isvalid(int val, int digits) {
  while (val) {
    val /= 10;
    digits--;
  }
  return digits == 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> arr(n, 0);
  while (m--) {
    int s, c;
    cin >> s >> c;
    arr[s - 1] = c;
  }
  int val = 0, base = 1;
  for (auto i = arr.rbegin(); i != arr.rend(); i++) {
    val += *i * base;
    base *= 10;
  }
  if (isvalid(val, n)) {
    cout << val;
  } else
    cout << -1;
  return 0;
}
