#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a;
  cout << '\n';
  err(++it, args...);
}
void read(vector<long long> &v) {
  for (int i = 0; i < v.size(); i++) cin >> v[i];
}
long long n, m, a, b, c, k, temp, x, y;
void solveforthiscase(const int &test) {
  cin >> n;
  cin >> m;
  long long dif[n + 1];
  for (int i = 0; i <= n; i++) dif[i] = -1;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if (dif[a] != -1 && dif[a] != b) {
      cout << -1;
      return;
    }
    dif[a] = b;
  }
  if (n > 1 && dif[1] == 0) {
    cout << -1;
    return;
  }
  if (n == 1) {
    cout << ((dif[1] == -1) ? 1 : dif[1]);
    return;
  }
  string s;
  s.resize(n);
  if (dif[1] == -1) dif[1] = 1;
  for (int i = 0; i < n; i++) {
    s[i] = '0';
    if (dif[i + 1] != -1) s[i] += dif[i + 1];
  }
  cout << s;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test = 1;
  for (int i = 1; i <= test; i++) {
    solveforthiscase(i);
  }
}
