
// Problem: C - Unexpressed
// Contest: AtCoder - Caddi Programming Contest 2021(AtCoder Beginner Contest
// 193) URL: https://atcoder.jp/contests/abc193/tasks/abc193_c Memory Limit:
// 1024 MB Time Limit: 2000 ms Powered by CP Editor
// (https://github.com/cpeditor/cpeditor)

/*-----------------------------------------------------------*/

#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define l long long
#define rep(i, x, n) for (i = x; i < n; i++)
#define all(a) a.begin(), a.end()
#define fill0(a) memset(a, 0, sizeof(a))
#define fill_1(a) memset(a, -1, sizeof(a))
#define pb push_back
#define v(n) vector<l> v(n)
#define mp(l) map<l, l> mp
#define mp1(s, l) map<string, l> mp1
#define s(x) x.size()
#define space cout << endl
#define YES cout << "YES\n"
#define Yes cout << "Yes\n"
#define NO cout << "NO\n"
#define No cout << "No\n"
#define mx 1e17
#define mn LONG_MIN
#define mod 1000000007
#define mode 998244351
#define in(a, x) binary_search(a.begin(), a.end(), x)
#define ina(a, n, x) binary_search(a, a + n, x)

#define see(args...)                         \
  {                                          \
    cerr << "LINE " << __LINE__;             \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr << endl;                            \
  }
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << ' ' << *it << " = " << a;
  err(++it, args...);
}
inline void op() { cout << '\n'; }
template <typename T, typename... Types>
inline void op(T var1, Types... var2) {
  cout << var1 << ' ';
  op(var2...);
}
inline void ip() {}
template <typename T, typename... Types>
inline void ip(T& var1, Types&... var2) {
  cin >> var1;
  ip(var2...);
}
template <typename T, typename U>
inline void min_self(T& x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void max_self(T& x, U y) {
  if (x < y) x = y;
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> pair) {
  return out << "(" << pair.first << ", " << pair.second << ")";
}
template <class T>
ostream& operator<<(ostream& out, vector<T> vec) {
  out << "(";
  for (auto& v : vec) out << v << ' ';
  return out << ")";
}
template <class T>
ostream& operator<<(ostream& out, set<T> vec) {
  out << "(";
  for (auto& v : vec) out << v << ", ";
  return out << ")";
}
template <class L, class R>
ostream& operator<<(ostream& out, map<L, R> vec) {
  out << "(";
  for (auto& v : vec) out << "[" << v.first << ", " << v.second << "]";
  return out << ")";
}
template <class A, class B>
istream& operator>>(istream& in, pair<A, B>& a) {
  return in >> a.first >> a.second;
}
template <class A>
istream& operator>>(istream& in, vector<A>& a) {
  for (A& i : a) in >> i;
  return in;
}
template <class Container>
void split(const std::string& str, Container& cont, char delim = ',') {
  stringstream ss(str);
  string token;
  while (std::getline(ss, token, delim)) {
    cont.push_back(token);
  }
}

void solve() {
  l n, i, j, k;
  ip(n);
  l ans = n;
  map<l, l> mp;
  for (i = 2; i <= 100005; i++) {
    l x = i * i;

    while (x < n) {
      if (mp[x] == 0) {
        ans--;
        mp[x]++;
      }
      x *= i;
    }
    if (x == n) {
      if (mp[x] == 0) {
        ans--;
        mp[x]++;
      }
    }
  }
  op(ans);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int t;
  t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}

	//IQ134高知能系Vtuberの高井茅乃です。
	//Twitter: https://twitter.com/takaichino
	//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

	#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;

	#define INF INT_MAX
	#define LLINF LLONG_MAX
	#define REP(i,n) for(int i=0;i<n;i++)
	#define REP1(i,n) for(int i=1;i<=n;i++)
	#define MODA 1000000007
	#define MODB  998244353 

	template <typename T>
	std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
		for (T& x: vec) { is >> x; }
		return is;
	}



	int main() {
		ll ans = 0;
		ll tmp = 0;
		int n; cin >> n;
		string s; cin >> s;
		vector<int> a(n+1); cin >> a;
		int mi[n+1] = {};
		REP(i, n) if(s[i] == '<') mi[i+1] = max(mi[i+1], mi[i]+1);
		for(int i = n; i >= 0; i--) if(s[i] == '>') mi[i] = max(mi[i], mi[i+1]+1);
		ans = INF;
		//REP(i, n+1) if(mi[i] > 0) ans = min(ans, (ll)(a[i]/mi[i]));
		REP(i, n) ans = min(ans, (ll)abs(a[i] - a[i+1]));
		cout << ans << endl;
		REP(i, ans){ REP(j, n+1){cout << (a[j] + i)/ ans << " ";} cout << endl;}
		//REP(i, ans - 1){ REP(j, n+1){cout << mi[j] << " ";} cout << endl;}
		//REP(i, n+1){cout << a[i] - mi[i] *(ans - 1) << " ";} cout << endl;
	}