#include <bits/stdc++.h>
using namespace std;
int on_bit(int N, int pos) { return N = N | (1 << pos); }
int off_bit(int N, int pos) { return N = N & ~(1 << pos); }
bool check_bit(long long int N, int pos) { return (bool)(N & (1 << pos)); }
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
int main() {
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << "1";
    for (int i = 1; i < n; i++) cout << "0";
    cout << "\n";
    return 0;
  }
  vector<pair<int, int> > v(m);
  for (int i = 0; i < m; i++) cin >> v[i].first >> v[i].second;
  (sort(v.begin(), v.end()),
   v.resize(distance(v.begin(), unique(v.begin(), v.end()))));
  bool flg = 0;
  for (int i = 0; i < v.size() - 1; i++) {
    if (v[i].first == v[i + 1].first) {
      flg = 1;
      break;
    }
  }
  if (flg)
    cout << "-1\n";
  else {
    int ar[10];
    memset((ar), -1, sizeof((ar)));
    for (int i = 0; i < v.size(); i++) {
      ar[v[i].first] = v[i].second;
    }
    if (ar[1] == -1 || ar[1] == 0)
      cout << "-1\n";
    else {
      for (int i = 1; i <= n; i++) {
        if (ar[i] != -1)
          cout << ar[i];
        else {
          if (i == 1)
            cout << "1";
          else
            cout << "0";
        }
      }
      cout << "\n";
    }
  }
  return 0;
}
