#include <bits/stdc++.h>
const long long pinf = ((long long)2e18);
const long long ninf = ((long long)-2e18);
const long long mod = 1000000007;
using namespace std;
long long power(long long x, long long n, long long M) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return power((x * x) % M, n / 2, M);
  else
    return (x * power((x * x) % M, (n - 1) / 2, M)) % M;
}
long long fact(long long n, long long M) {
  long long r = 1;
  for (long long i = 0; i < n; i++) {
    r = (r * (i + 1)) % M;
  }
  return r;
}
long long cons_freq(long long a[], long long n, long long p, long long q) {
  long long c = 0;
  for (long long i = p; i < n; i++) {
    if (a[i] == q)
      c++;
    else
      break;
  }
  return c;
}
long long binary_search(long long a[], long long low, long long high,
                        long long key) {
  while (low <= high) {
    long long mid = low + (high - low) / 2;
    if (a[mid] < key)
      low = mid + 1;
    else if (a[mid] > key)
      high = mid - 1;
    else
      return mid;
  }
  return -1;
}
bool check_perfect_square(long long n) {
  return (sqrt(n) - floor(sqrt(n)) == 0);
}
bool check_prime(long long n) {
  if (n < 2) return false;
  for (long long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return true;
}
bool check_pali(string s) {
  string str = s;
  reverse(str.begin(), str.end());
  return str == s;
}
void dfs(vector<long long> adj[], bool vis[], long long s) {
  vis[s] = true;
  for (long long i = 0; i < adj[s].size(); i++) {
    if (!vis[adj[s][i]]) dfs(adj, vis, adj[s][i]);
  }
}
void bfs(vector<long long> adj[], bool vis[], long long s) {
  queue<long long> q;
  q.push(s);
  vis[s] = true;
  while (!q.empty()) {
    long long v = q.front();
    q.pop();
    for (long long i = 0; i < adj[v].size(); i++) {
      if (!vis[adj[v][i]]) {
        vis[adj[v][i]] = true;
        q.push(adj[v][i]);
      }
    }
  }
}
void dijkstra(vector<pair<long long, long long> > adj[], long long src,
              bool vis[], long long dist[], long long n) {
  multiset<pair<long long, long long> > s;
  s.insert(make_pair(0, src));
  while (!s.empty()) {
    pair<long long, long long> p = *s.begin();
    s.erase(s.begin());
    long long d = p.first, v = p.second;
    if (vis[v]) continue;
    vis[v] = true;
    for (long long i = 0; i < adj[v].size(); i++) {
      if (dist[v] + adj[v][i].second < dist[adj[v][i].first]) {
        dist[adj[v][i].first] = dist[v] + adj[v][i].second;
        s.insert(make_pair(dist[adj[v][i].first], adj[v][i].first));
      }
    }
  }
}
long long Kadane(long long a[], long long n) {
  long long dp[n];
  dp[n - 1] = a[n - 1];
  for (long long i = n - 2; i >= 0; i--) {
    dp[i] = max(dp[i + 1] + a[i], a[i]);
  }
  return *max_element(dp, dp + n);
}
long long digits(long long n) {
  long long c = 0;
  while (n) {
    c++;
    n /= 10;
  }
  return c;
}
long long setbits(long long n) { return __builtin_popcount(n); }
int32_t main() {
  ;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, s, c;
  cin >> n >> m;
  char a[n];
  for (long long i = 0; i < n; i++) a[i] = '$';
  for (long long i = 0; i < m; i++) {
    cin >> s >> c;
    if (a[s - 1] == '$')
      a[s - 1] = c + 48;
    else {
      if (a[s - 1] != (c + 48)) {
        cout << "-1";
        return 0;
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    if (i == 0) {
      if (a[i] == '$') a[i] = '1';
    } else {
      if (a[i] == '$') a[i] = '0';
    }
  }
  if (n > 1) {
    if (a[0] == '0') {
      cout << "-1";
      return 0;
    }
  }
  for (long long i = 0; i < n; i++) cout << a[i];
  return 0;
}
