#include <bits/stdc++.h>
using namespace std;
template <class T>
T maxT(T a, T b) {
  return (a > b ? a : b);
}
template <class T>
T minT(T a, T b) {
  return (a < b ? a : b);
}
template <class T>
void setmax(T &a, T b) {
  a = (a > b ? a : b);
}
template <class T>
void setmin(T &a, T b) {
  a = (a < b ? a : b);
}
void fileio() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("debug.txt", "w", stderr);
}
void ofileio() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void clock_out() {
  cerr << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
const long long MOD = 1000000007;
const long long SIZE = 100000;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const long double PI = acos(-1);
const long long MAXN = numeric_limits<long long>::max();
void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > s(m);
  for (long long i = 0; i < (long long)m; i++) cin >> s[i].first >> s[i].second;
  vector<int> res(n, -1);
  for (long long i = 0; i < (long long)m; i++) {
    int ind = s[i].first;
    ind--;
    int val = s[i].second;
    if (res[ind] == (-1)) {
      res[ind] = val;
    } else if (res[ind] != -1 && res[ind] != val) {
      cout << -1;
      return;
    }
  }
  if (res[0] == -1) res[0] = 1;
  if (res[0] == 0 && n > 1) {
    cout << -1;
    return;
  }
  for (long long i = 0; i < (long long)n; i++) {
    if (res[i] == -1) res[i] = 0;
    cout << res[i];
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  long long t = 1;
  while (t--) {
    solve();
  }
  1;
  return 0;
}
