#include <bits/stdc++.h>
using namespace std;
inline void fileio(const char* in, const char* out) {
  freopen(in, "r", stdin);
  freopen(out, "w", stdout);
}
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> VI;
typedef vector<bool> VB;
typedef vector<ll> VL;
const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const ld EPS = 1e-9, PI = acos(-1);
const int N = 5;
int dig[N];
void fail() {
  cout << -1 << nl;
  exit(0);
}
int main() {
  atexit([]() { cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12);
  int n, m;
  cin >> n >> m;
  memset(dig, -1, sizeof dig);
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    s--;
    if (dig[s] == -1 || dig[s] == c) {
      dig[s] = c;
      continue;
    }
    fail();
  }
  if (dig[0] == 0 && n > 1) fail();
  for (int i = 0; i < n; ++i) {
    if (dig[i] == -1) dig[i] = i == 0;
    cout << dig[i];
  }
  cout << nl;
  return 0;
}
