#include <bits/stdc++.h>
using namespace std;
const int N = 5;
int n, m, s, c, dp[N];
bool ok = true;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) dp[i] = -1;
  while (m--) {
    cin >> s >> c;
    if (dp[s] == -1)
      dp[s] = c;
    else if (dp[s] != c)
      ok = false;
  }
  if (dp[1] != -1 and dp[1] == 0) ok = false;
  if (dp[1] == -1) {
    if (n == 1)
      dp[1] = 1;
    else
      dp[1] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (dp[i] == -1) dp[i] = 0;
  if (ok) {
    for (int i = 1; i <= n; i++) cout << dp[i];
  } else
    cout << "-1";
}
