#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = ll(1e10) + 1;
void Main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(n, -1);
  for (int i = 0; i < (m); ++i) {
    int s, c;
    cin >> s >> c;
    s--;
    if (A[s] != -1) {
      if (A[s] != c) {
        cout << -1 << endl;
        return;
      }
    }
    A[s] = c;
  }
  if (A[0] == 0) {
    cout << -1 << endl;
    return;
  }
  if (A[0] == -1) A[0] = 1;
  for (int i = (1); i < (n); ++i)
    if (A[i] == -1) A[i] = 0;
  for (int i = 0; i < (n); ++i) cout << A[i];
  cout << endl;
  return;
}
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}
