#pragma GCC optimize("Ofast")
// #include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <chrono>
#include <algorithm>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns the iterator to kth largest element.(0-based)
#define int long long
#define pb push_back
#define endl "\n"
#define all(con) con.begin(), con.end()
#define fi first
#define se second
#define F first
#define S second
#define MP make_pair
#define sz(x) (int)x.size()
#define rp(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define fff(i, a, b) for (int i = a; i < b; i++)
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " || ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<pair<int, int>> vpi;
const int mod = 1e9 + 7;
const int mod1 = 998244353;
const int inf = 2e18;
// const int MOD = 998244353;
const int MOD = 1e9 + 7;
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vectors-
int bitcount(int n)
{
    return (__builtin_popcountll(n));
}
// check if a number is a power of 2
bool isp2(int n) { return (__builtin_popcountll(n) == 1); }
// int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return (a * b) / (__gcd(a, b)); }
// Euclidean Algorithm for computing greatest Common Divisor
int gcd(int a, int b)
{
    if (!a || !b)
        return a | b;
    unsigned shift = __builtin_ctz(a | b);
    a >>= __builtin_ctz(a);
    do
    {
        b >>= __builtin_ctz(b);
        if (a > b)
            swap(a, b);
        b -= a;
    } while (b);
    return a << shift;
}
// Recursively computes the power
int binpow(int a, int b)
{
    if (b == 0)
        return a;
    int res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
// iteratively computes the power
int pow(int a, int b)
{
    int res = 1;
    while (b)
    {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
int modpow(int a, int b, int m)
{
    int ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (ans * a) % m;
        b /= 2;
        a = (a * a) % m;
    }
    return ans;
}
bool isprime(int n)
{
    if (n < 2)
        return false;
    if (n == 2)
        return true;
    if (n % 2 == 0)
        return false;
    for (int i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}
const int MXX = 1e5 + 69;
int fact[MXX], invfact[MXX];
int modinv(int k) { return modpow(k, MOD - 2, MOD); }
void combinatorics()
{
    fact[0] = fact[1] = 1;
    for (int i = 2; i < MXX; i++)
    {
        fact[i] = fact[i - 1] * i;
        fact[i] %= MOD;
    }
    invfact[MXX - 1] = modinv(fact[MXX - 1]);
    for (int i = MXX - 2; i >= 0; i--)
    {
        invfact[i] = invfact[i + 1] * (i + 1);
        invfact[i] %= MOD;
    }
}
int nCr(int x, int y)
{
    if (y > x)
        return 0;
    int num = fact[x];
    num *= invfact[y];
    num %= MOD;
    num *= invfact[x - y];
    num %= MOD;
    return num;
}
// transforms a string into lowercase.
string lwr(string s)
{
    transform(all(s), s.begin(), ::tolower);
    return s;
}
// transforms a string into uppercase.
string upr(string s)
{
    transform(all(s), s.begin(), ::toupper);
    return s;
}
// factorize a given number
vector<int> factorize(int n)
{
    vector<int> v;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            v.push_back(i);
            if (i * i != n)
            {
                v.push_back(n / i);
            }
        }
    }
    sort(v.begin(), v.end());
    return v;
}
// Implementation of Disjoint Set Union
// using path compression and union by size.
// Grows very slowly - inverse ackermann function
// Link to dsu : https://cp-algorithms.com/data_structures/disjoint_set_union.html
class DSU
{
public:
    vector<int> par, sz;
    // Constructor for Initializing
    DSU(int n)
    {
        n = n + 3;
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; i++)
            par[i] = i, sz[i] = 1;
    }
    // Returns the main parent/representative of the set
    int find(int x)
    {
        if (x == par[x])
            return par[x];
        else
            return (par[x] = find(par[x])); // Path Compression Optimization
        //  first find the representative of the set (root vertex), and the in the process of stack unwinding,
        // the visited nodes are attached directly to the representative.
    }
    // Unite two sets
    void Unite(int x, int y) // Union by Size
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (sz[x] < sz[y])
            swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
    bool Same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return sz[find(x)]; }
};
// Stack is LIFO (Last in First Out)
// Linked List based implementation of stacks
// It is better tham the implementation using arrays.
// Because it is dynamic
// In the main function, call it as StackNode sn; StackNode *root = NULL; root = all operations.
class StackNode
{
public:
    int data;
    StackNode *next;
    // Creates a new node to push onto the stack
    StackNode *CreateNode(int val)
    {
        StackNode *snw = new StackNode();
        snw->data = val;
        snw->next = NULL;
    }
    // Checks if the stack is empty
    int isEmpty(StackNode *root)
    {
        return (!root);
    }
    // Pushes a new-node onto the stack
    StackNode *push(StackNode *root, int val)
    {
        StackNode *nn = CreateNode(val);
        nn->next = root;
        root = nn;
        return root;
    }
    // remove the topmost element from the stack.
    StackNode *pop(StackNode *root)
    {
        if (isEmpty(root))
            return NULL;
        StackNode *tmp = root;
        (root) = (root)->next;
        int popped = tmp->data;
        free(tmp);
        return root;
    }
    // Returns the topmost element of the stack.
    int peek(StackNode *root)
    {
        if (isEmpty(root))
            return -2e9;
        return root->data;
    }
    // Returns the size of the stack
    int size(StackNode *root)
    {
        StackNode *a = root;
        int ans = 0;
        while (a != NULL)
        {
            a = a->next;
            ans++;
        }
        return ans;
    }
};
// Node representing a node of a Queue
class QNode
{
public:
    int data;
    QNode *next;
    QNode(int val)
    {
        data = val;
        next = NULL;
    }
};
// Class for operations on a Queue
// Queue is LIFO Last in First Out
class Queue
{
public:
    QNode *front;
    QNode *rear;
    Queue()
    {
        front = rear = NULL;
    }
    // Adding an element
    void EnQueue(int x)
    {
        QNode *tmp = new QNode(x);
        if (rear == NULL)
        {
            front = rear = tmp;
            return;
        }
        rear->next = tmp;
        rear = tmp;
    }
    // Removing an element
    void DeQueue()
    {
        if (front == NULL)
            return;
        QNode *tmp = front;
        front = front->next;
        if (front == NULL)
            rear = NULL;
        delete (tmp);
    }
    // To access the first element of the Queue
    int Front()
    {
        return front->data;
    }
    // To access the last element of the Queue
    int Back()
    {
        return rear->data;
    }
    // Check if the Queue is Empty
    bool isEmpty()
    {
        return front == rear and front == NULL;
    }
    // Prints the elements of the Queue
    void displayQueue()
    {
        QNode *a = front;
        while (a != NULL)
        {
            cout << (a->data) << " ";
            a = a->next;
        }
        cout << endl;
    }
};
// Function to print a vector
template <typename T>
void prev(vector<T> &v)
{
    for (auto t : v)
        cout << t << " ";
    cout << endl;
}
// Function to print a vector and its size too
template <typename T>
void prevs(vector<T> &v)
{
    cout << v.size() << endl;
    for (auto t : v)
        cout << t << " ";
    cout << endl;
}
// Function to print an array
void prar(int a[], int n, int x)
{
    for (int i = 0 + x; i < n + x; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}
template <typename T>
std::pair<bool, int> findInVector(const std::vector<T> &vecOfElements, const T &element)
{
    std::pair<bool, int> result;
    auto it = std::find(vecOfElements.begin(), vecOfElements.end(), element);
    if (it != vecOfElements.end())
    {
        result.second = distance(vecOfElements.begin(), it);
        result.first = true;
    }
    else
    {
        result.first = false;
        result.second = -1;
    }
    return result;
}
// function to check if a character is a vowel.
bool isvowel(char ch)
{
    string s = "aeiouAEIOU";
    for (char c : s)
        if (c == ch)
            return true;
    return false;
}
const int infms = 2e18;
int inversions = 0;
void Merge(int a[], int start, int mid, int end)
{
    int n1 = mid - start + 1;
    int n2 = end - mid;
    int left[n1 + 2];
    int right[n2 + 2];
    left[n1 + 1] = infms;
    right[n2 + 1] = infms;
    for (int i = 1; i <= n1; i++)
    {
        left[i] = a[start + i - 1];
    }
    for (int i = 1; i <= n2; i++)
    {
        right[i] = a[mid + i];
    }
    int x = 1, y = 1;
    for (int k = start; k <= end; k++)
    {
        if (left[x] <= right[y])
        {
            a[k] = left[x];
            x++;
        }
        else
        {
            inversions += (1 + n1 - x);
            a[k] = right[y];
            y++;
        }
    }
}
// Merge Sort algorithm
void MergeSort(int a[], int start, int end)
{
    if (start < end)
    {
        int mid = (start + end) / 2;
        MergeSort(a, start, mid);
        MergeSort(a, mid + 1, end);
        Merge(a, start, mid, end);
    }
}
// Recursive function to check if string is a palindrome
bool ispalindrome(string s)
{
    int n = s.length();
    if (n <= 1)
        return true;
    else if (n == 2 && s[1] == s[0])
        return true;
    else if (n == 2 && s[0] != s[1])
        return false;
    else if (s[0] != s[n - 1])
        return false;
    else
        return ispalindrome(s.substr(1, n - 2));
}
bool palindrome(string s)
{
    string t = s;
    reverse(all(t));
    return (t == s);
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
void dream();
auto clk = clock();
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << setprecision(8);
    // while( (double)clock() / CLOCKS_PER_SEC < 0.95 ) // can be used in special cases
    // #ifndef ONLINE_JUDGE // Comment this if the question demands input-output through a file
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // #endif
    // combinatorics(); // Take care of MOD
    int TESTCASES = 1;
    // cin>>TESTCASES;
    for (int i = 1; i <= TESTCASES; i++)
        dream();

#ifndef ONLINE_JUDGE
    cout << endl
         << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl
         << endl;
#endif
    return 0;
}
void dream()
{
    int n, b;
    cin >> n >> b;
    int a[n];
    rp(i, n) cin >> a[i];
    int64_t a1 = 0;
    rp(i, n)
    {
        a1 = a1 + a[i] * pow(b, n - 1 - i);
    }
    cin >> n >> b;
    rp(i, n) cin >> a[i];
    int64_t a2 = 0;
    rp(i, n)
    {
        a2 = a2 + a[i] * pow(b, n - 1 - i);
    }
    trace(a1, a2);
    if (a1 == a2)
    {
        cout << "=" << endl;
    }
    else if (a1 < a2)
    {
        cout << "<" << endl;
    }
    else
    {
        cout << ">" << endl;
    }
    // you should actually read the stuff at the bottom
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
    * boundary cases
	* do something instead of nothing and stay organized.
    * BELIEVE in yourself.
*/
/* some basic stuff that you should learn:
        * Sets : Unique element container.
            * set<int,greater<int> > s; // to order the set in descending order
            * To check if an element is in a set : s.count(x)  || s.find(x)!=s.end()
            * begin() - returns an iterator to first element of set. The value of the element can be accessed using *(s.begin())
            * end() - Returns an iterator to the theoretical element that follows last element in the set.
            * size() - Returns the number of elements in the set.
            * max_size() - Returns the maximum number of elements that the set can hold.
            * empty() - Returns whether the set is empty.
            * find(x) - Returns an iterator to the element ‘x’ in the set if found, else returns the iterator to end.
            * erase(x)– Removes the value ‘x’ from the set. It erases an element by value
            * count(x) - Returns 1 or 0 based on the element ‘x’ is present in the set or not. It's the best way to check for the presence of an element.
            * lower_bound(x) – Returns an iterator to the first element that is equivalent to ‘x’ or definitely will not go before the element ‘x’ in the set.
              lower_bound can also be thought as the smallest element greater than or equal to x
            * Return reverse iterator to reverse beginning: (s.rbegin())
            * Set to be sorted in decreasing order: set<int, greater<int> >
            * emplace() : If the function successfully inserts the element (because no
                    equivalent element existed already in the set), the function returns a
                    pair of an iterator to the newly inserted element and a value of true.
            * const bool is_in = s.find(x) != s.end(); check if an element is in the set.
            * myset.erase(x) #directly by value. logarithmic complexity
            * myset.erase(iteratortoanelement,s.end())
            * for_each(all(s),do_something);
            * set<int> :: iterator it = myset.find(60);

        * Vectors
            vector<int> v; v.resize(n,0); // resizes the vector and initializes it too.
            front(), back(), push_back(), pop_back()
            * begin() - Returns an iterator pointing to the first element in the vector
            * end() - Returns an iterator pointing to the theoretical element that follows the last element in the vector
            * rbegin() - Returns a reverse iterator pointing to the last element in the vector (reverse beginning).
            * rend() - Returns a reverse iterator pointing to the theoretical element preceding the first element in the vector
            * cbegin(),cend(),crbegin(),crend()
            * size() - Returns the number of elements in the vector.
            * max_size() -  Returns the maximum number of elements that the vector can hold.
            * capacity() - Returns the size of the storage space currently allocated to the vector expressed as number of elements.
            * resize() - Resizes the container so that it contains ‘n’ elements.
            * empty() - Returns whether the container is empty.
            * shrink_to_fit() - Reduces the capacity of the container to fit its size and destroys all elements beyond the capacity.
            * reserve() - Requests that the vector capacity be at least enough to contain n elements.
            * [i] - Returns a reference to the element at position ‘i’ in the vector
            * at(i) - Returns a reference to the element at position ‘i’ in the vector
            * front() - Returns a reference to the first element in the vector
            * back() - Returns a reference to the last element in the vector
            * data() - Returns a direct pointer to the memory array used internally by the vector to store its owned elements.
            * assign() - It assigns new value to the vector elements by replacing old ones
            * push_back() - It push the elements into a vector from the back
            * pop_back() - It is used to pop or remove elements from a vector from the back.
            * insert() - It inserts new elements before the element at the specified position
            * erase() - It is used to remove elements from a container from the specified position or range
            * swap() - It is used to swap the contents of one vector with another vector of same type. Sizes may differ.
            * clear() - It is used to remove all the elements of the vector container
            * emplace() - It extends the container by inserting new element at position
            * emplace_back() - It is used to insert a new element into the vector container, the new element is added to the end of the vector
            * for (auto it = myvector.begin(); it != myvector.end(); ++it)

        * Queue
            * empty() - Returns whether the queue is empty.
            * size() - Returns the size of the queue.
            * emplace() - Insert a new element into the queue container, the new element is added to the end of the queue.
            * front() - front() function returns a reference to the first element of the queue.
            * back() - returns a reference to the last element of the queue.
            * push(x) - adds the element ‘x’ at the end of the queue
            * pop() - deletes the first element of the queue

        * Priority_Queue
            priority_queue <int, vector<int>, greater<int>> pq; // to make a priority queue in descending order
            * empty() - returns whether the queue is empty.
            * size() -  returns the size of the queue.
            * top() -  Returns a reference to the top most element of the queue
            * push(x) - adds the element ‘x’ at the end of the queue.
            * pop() -  deletes the first element of the queue.
            * swap() -  swap the contents of one priority queue with another priority queue of same type and size.
            * emplace() - insert a new element into the priority queue container, the new element is added to the top of the priority queue.

        * Deque
            Double ended queues are sequence containers with the feature of expansion and contraction on both the ends.
            They are similar to vectors, but are more efficient in case of insertion and deletion of elements.
            Unlike vectors, contiguous storage allocation may not be guaranteed.
            * insert()
            * rbegin()
            * rend()
            * assign()
            * resize()
            * push_front()
            * push_back()
            * pop_front()
            * pop_back()
            * front()
            * back()
*/


#define _CRT_SECURE_NO_WARNINGS
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

void fast(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);

	#endif
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
int n;

int main(){
	fast();
	cin>>n;
	long long a , b, c;
	a = n , b =1 , c = 1;
	long long mx = (a+1) * (b +2)*(c+2) - n;
	for(int i = 1;i*i <= n ;i++){
		if(n%i == 0){
			b = i;
		}
	}
	a = n /b;
	long long mn = (min(a,b)+2) * (max(a,b) +2)*(c+1) - n;
	cout<<mn<<" "<<mx<<endl;
	return 0;
}


#include <iostream>
#include <string>

using namespace std;

int findGCD(int a, int b){
	int temp;
	if (a < b){
		temp = a;
		a = b;
		b = temp;
	}
	while(true){
		a %= b;
		if (a == 0) break;
		temp = a;
		a = b;
		b = temp;
	}
	return b;
}

int main() {
	int a, b, n, temp;
	cin >> a >> b >> n;
	while (true){
		temp = findGCD(a, n);
		if (n < temp){
			cout << "1";
			break;
		}
		n -= a;
		temp = findGCD(b, n);
		if (n < temp){
			cout << "0";
			break;
		}
		n -= b;
	}
}


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

typedef long long llint;
typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MOD = 998244353;

namespace FFT {
  const int MAX = 3 * (1 << 20);

  typedef llint value;
  typedef complex<double> comp;

  int N;
  comp omega[MAX];
  comp a1[MAX], a2[MAX];
  comp z1[MAX], z2[MAX];

  void fft(comp *a, comp *z, int m = N) {
    if (m == 1) {
      z[0] = a[0];
    } else {
      int s = N/m;
      m /= 2;

      fft(a, z, m);
      fft(a+s, z+m, m);

      REP(i, m) {
        comp c = omega[s*i] * z[m+i];
        z[m+i] = z[i] - c;
        z[i] += c;
      }
    }
  }

  void mult(value *a, value *b, value *c, int len) {
    N = 2*len;
    while (N & (N-1)) ++N;
    assert(N <= MAX);

    REP(i, N) a1[i] = 0;
    REP(i, N) a2[i] = 0;
    REP(i, len) a1[i] = a[i];
    REP(i, len) a2[i] = b[i];

    REP(i, N) omega[i] = polar(1.0, 2*M_PI/N*i);
    fft(a1, z1, N);
    fft(a2, z2, N);

    REP(i, N) omega[i] = comp(1, 0) / omega[i];
    REP(i, N) a1[i] = z1[i] * z2[i] / comp(N, 0);
    fft(a1, z1, N);

    REP(i, 2*len) c[i] = round(z1[i].real());
  }

  void mult_mod(llint *a, llint *b, llint *c, int len, int mod) {
    static llint a0[MAX], a1[MAX];
    static llint b0[MAX], b1[MAX];
    static llint c0[MAX], c1[MAX], c2[MAX];

    REP(i, len) a0[i] = a[i] & 0xFFFF;
    REP(i, len) a1[i] = a[i] >> 16;

    REP(i, len) b0[i] = b[i] & 0xFFFF;
    REP(i, len) b1[i] = b[i] >> 16;

    FFT::mult(a0, b0, c0, len);
    FFT::mult(a1, b1, c2, len);

    REP(i, len) a0[i] += a1[i];
    REP(i, len) b0[i] += b1[i];
    FFT::mult(a0, b0, c1, len);
    REP(i, 2*len) c1[i] -= c0[i] + c2[i];

    REP(i, 2*len) c1[i] %= mod;
    REP(i, 2*len) c2[i] %= mod;
    REP(i, 2*len) c[i] = (c0[i] + (c1[i] << 16) + (c2[i] << 32)) % mod;
  }
}

int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}

int mul(int a, int b) {
  return (ll)a * b % MOD;
}

int n, k;
llint p[FFT::MAX], ans[FFT::MAX];

int main() {
  scanf("%d %d",&n,&k);
  REP(i, k) {
    int a;
    cin >> a;
    p[a] = 1;
  }
  ans[0] = 1;

  n /= 2;

  int sz = 10;
  while (n) {
    if (n % 2) FFT::mult_mod(p, ans, ans, sz, MOD);
    FFT::mult_mod(p, p, p, sz, MOD);
    n /= 2;
    sz *= 2;
  }

  int sol = 0;

  REP(i, FFT::MAX) {
    sol = add(sol, mul(ans[i], ans[i]));
  }

  cout << sol << endl;
  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <memory.h>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
const double eps = 1e-9;
const int INF = 1<<30;
const LL LINF = 1ll<<61;

#define pb push_back
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define CLR(a, v) memset((a),(v),sizeof(a))
#define sqr(a) ((a)*(a))
const int BUFFER_SZ = 1<<20;
const int MOD = 1000*1000*1000+7;

char BUFFER[BUFFER_SZ];
int gi() { int x; scanf("%d", &x); return x; }
double gd() { double x; scanf("%lf", &x); return x; }
LL gll() { LL x; scanf("%lld", &x); return x; }
VI gvi(int n) { VI a; while(n-->0) a.pb(gi()); return a;}
string gs() { scanf("%s", BUFFER); return string(BUFFER); }
template <class T> void print(vector<T> &x, string format) { format += "%c";for (int i = 0; i < x.size(); ++i) printf(format.c_str(), x[i], i+1==x.size() ? '\n' : ' '); }
// ---------------------------------------------------------- //

struct point {
  double x,y;
  point(double x, double y):x(x),y(y) {}
};

struct line {
  double A,B,C;
  line(point a, point b) {
    A = a.y-b.y;
    B = b.x-a.x;
    C = -A*a.x-B*a.y;
  }
};

struct seg {
  point p,q;
  seg(point p,point q):p(p),q(q) {}
};

int intersects(line a, line b) {
  return abs(a.A*b.B-b.A*a.B)>eps;
}

double dist(line a, point p) {
  return (a.A*p.x + a.B*p.y + a.C) / hypot(a.A, a.B);
}
double dist(seg a, point p) {
  return dist(line(a.p, a.q), p);
}

point intersectLines(line a, line b) {
  double det = a.A*b.B-b.A*a.B;
  double x = -(a.C*b.B-a.B*b.C)/det;
  double y = -(a.A*b.C-a.C*b.A)/det;
  return point(x,y);
}

int intersect(seg a, seg b, int allowCollision=0) {
  line la = line(a.p, a.q);
  line lb = line(b.p, b.q);

  double x1 = min(a.p.x, a.q.x);
  double x2 = max(a.p.x, a.q.x);
  double y1 = min(a.p.y, a.q.y);
  double y2 = max(a.p.y, a.q.y);

  double x3 = min(b.p.x, b.q.x);
  double x4 = max(b.p.x, b.q.x);
  double y3 = min(b.p.y, b.q.y);
  double y4 = max(b.p.y, b.q.y);

  if (min(x2,x4)-max(x1,x3)<-eps) return 0;
  if (min(y2,y4)-max(y1,y3)<-eps) return 0;

  if (intersects(la,lb)) {
    point c = intersectLines(la,lb);
    if (x1-eps<c.x && c.x < x2+eps
        && y1-eps<c.y && c.y < y2+eps) return 1;
    return 0;
  } else {
    if (abs(dist(la,b.p))<eps) {
      return !allowCollision;
    }
    return 0;
  }
}

void solve() {
  double x1 = gd();
  double y1 = gd();

  double x2 = gd();
  double y2 = gd();

  double xw1 = gd();
  double yw1 = gd();
  double xw2 = gd();
  double yw2 = gd();

  double xm1 = gd();
  double ym1 = gd();
  double xm2 = gd();
  double ym2 = gd();

  seg wall(point(xw1,yw1), point(xw2,yw2));
  seg mirr(point(xm1,ym1), point(xm2,ym2));

  seg direct(point(x1,y1), point(x2,y2));

  // direct view:
  if (!intersect(direct,wall) && !intersect(direct,mirr,1)) {
    printf("YES\n");
    return;
  }

  // through the mirror:
  point A(x1,y1);
  point B(x2,y2);
  double d1 = dist(mirr,A);
  double d2 = dist(mirr,B);
  if (abs(d1)<eps || abs(d2)<eps) {
    // can't look through
  } else {
    if (d1<0.0 && d2>0.0 || d1>0.0 && d2<0.0) {
      // different sides
    } else {
      //cout << "here" << endl;
      line mirrL(mirr.p, mirr.q);
      double vx = mirrL.A;
      double vy = mirrL.B;
      vx/=hypot(mirrL.A, mirrL.B);
      vy/=hypot(mirrL.A, mirrL.B);

      double px = A.x-vx*d1;
      double py = A.y-vy*d1;

      double p2x = B.x-vx*d2;
      double p2y = B.y-vy*d2;

      double d = hypot(px-p2x, py-p2y);
      //printf("%.3lf\n", d);
      //printf("%.3lf %.3lf\n", px, py);

      double move = d1*d/(d1+d2);
      //printf("%.3lf\n", move);
      double ox = px+(p2x-px)*move/d;
      double oy = py+(p2y-py)*move/d;
      //printf("%.3lf %.3lf\n", ox, oy);

      seg t1(A,point(ox,oy));
      seg t2(B,point(ox,oy));
      if (intersect(mirr, t1) && intersect(mirr,t2)) {
        if (!intersect(wall,t1) && !intersect(wall,t2)) {
          printf("YES\n");
          return;
        }
      }
    }
  }
  printf("NO\n");
}

int main() {
#ifdef DEAD_RABBIT
  freopen("../in.txt","r",stdin);
  clock_t start = clock();
#endif
  solve();
#ifdef DEAD_RABBIT
  fprintf(stdout, "Time: %.3lf\n", 1.0*(clock()-start)/CLOCKS_PER_SEC);
#endif
  return 0;
}


#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 1010;
ld F[N][M]; int vis[N][M];

ld f(int n, int m) {
    if(!n) return (ld) 1 / (m + 1);
    if(!m) return 1;
    if(vis[n][m]) return F[n][m];
    ld k1 = (ld) m / (m + 1) * (1 - f(m - 1, n)) - 1;
    ld b1 = 1;
    ld k2 = (ld) (1 + m * (1 - f(m - 1, n))) / (m + 1) - (1 - f(m, n - 1));
    ld b2 = 1 - f(m, n - 1);
    ld X = (b2 - b1)  / (k1 - k2);
    vis[n][m] = 1;
    return F[n][m] = k1 * X + b1;
}

int main() {
    int n, m; cin >> n >> m;
    ld ans = f(n, m);
    cout << fixed << setprecision(10) << ans << ' ' << (1 - ans) << endl;
}


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

int main()
{
	int n, m;
	vector <int> base, ans;

	scanf("%d%d", &n, &m);

	for(int i = 1; i <= n; i++) base.push_back(i);

	for(int i = 0; i < n; i++) {
		ans.push_back(m%(i+2));
		m /= (i+2);
	}

	for(int i = 0; i < n; i++) {
//		cout << ans[i] << endl;
		printf("%d ", base[ans[i]]);
		base.erase(base.begin()+ans[i]);
	}
	cout << endl;

	return 0;
}


    #include <bits/stdc++.h>
    #define ll long long
    #define f(i,a,b) for(long long i=a;i<b;i++)
    const double pai=3.1415926536;
    using namespace std;

    int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<string> str;
    int sum=0,n,m;
    string x;
    cin>>n>>m;
    f(i,0,n)
    {
    cin>>x;
    str.push_back(x);
    }
    f(i,0,n){
    f(j,0,m){
    if(str[i][j]=='W'){

    //اى حرف فى النص
    if(i>0&&i!=n-1&&j>0&&j!=m-1){
    if(str[i][j-1]=='P'){sum++;str[i][j-1]='.'; continue;}
    if(str[i][j+1]=='P'){sum++;str[i][j+1]='.'; continue;}
    if(str[i-1][j]=='P'){sum++;str[i-1][j]='.'; continue;}
    if(str[i+1][j]=='P'){sum++;str[i+1][j]='.'; continue;}
    continue;

    }

    ////////////الاركان/////////

    //الحرف اللى تحت على الشمال
if(i>0&&i==n-1&&j==0&&j!=m-1){
    if(str[i][j+1]=='P'){sum++;str[i][j+1]='.';    continue;}
    if(str[i-1][j]=='P'){sum++;str[i-1][j]='.';    continue;}

    }

//الحرف اللى فوق على الشمال

    if(i==0&&i!=n-1&&j==0&&j!=m-1){
    if(str[i][j+1]=='P'){sum++;str[i][j+1]='.'; continue;}
    if(str[i+1][j]=='P'){sum++;str[i+1][j]='.'; continue;}

    }

    //الحرف فى الركن اللى تحت على اليمين
    if(i>0&&i==n-1&&j>0&&j==m-1){
    if(str[i][j-1]=='P'){sum++;str[i][j-1]='.'; continue;}
    if(str[i-1][j]=='P'){sum++;str[i-1][j]='.'; continue;}

    }

    //الحرف اللى فى الركن اللى فوق عل ىاليمين
    if(i==0&&i!=n-1&&j>0&&j==m-1){
    if(str[i][j-1]=='P'){sum++;str[i][j-1]='.'; continue;}
    if(str[i+1][j]=='P'){sum++;str[i+1][j]='.'; continue;}

    }

    //////الحواااف////////

//اى حرف فى اخر عمود
    if(i>0&&i!=n-1&&j==m-1){
    if(str[i][j-1]=='P'){sum++;str[i][j-1]='.'; continue;}
    if(str[i-1][j]=='P'){sum++;str[i-1][j]='.'; continue;}
    if(str[i+1][j]=='P'){sum++;str[i+1][j]='.'; continue;}

    }

//اى حرف فى اول صف
    if(i==0&&j>0&&j!=m-1){
    if(str[i][j-1]=='P'){sum++;str[i][j-1]='.'; continue;}
    if(str[i][j+1]=='P'){sum++;str[i][j+1]='.'; continue;}
    if(str[i+1][j]=='P'){sum++;str[i+1][j]='.'; continue;}

    }

    //اى حرف فى اخر صف

    if(i==n-1&&j>0&&j!=m-1){
    if(str[i][j-1]=='P'){sum++;str[i][j-1]='.'; continue;}
    if(str[i][j+1]=='P'){sum++;str[i][j+1]='.'; continue;}
    if(str[i-1][j]=='P'){sum++;str[i-1][j]='.'; continue;}
    }

    //اى حرف فى اول عمود

    if(i>0&&i!=n-1&&j==0){
    if(str[i][j+1]=='P'){sum++;str[i][j+1]='.'; continue;}
    if(str[i-1][j]=='P'){sum++;str[i-1][j]='.'; continue;}
    if(str[i+1][j]=='P'){sum++;str[i+1][j]='.'; continue;}

    }

    }
    }
    }
    cout<<sum;

    return 0;

    }


#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cstdlib>
using namespace std;
int a[100001];
inline int read()
{
    bool f=0;
    char c=getchar();
    int x=0;
    while(c<'0'||c>'9') f=!f,c=getchar();
    while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return f?-x:x;
}
inline void write(int n)
{
    if(n<0)
    {
        putchar('-');
        write(-n);
    }
    else
    {
        while(n/10) write(n%10);
        putchar(n%10+'0');
    }
}
int main()
{
    int n,k,ans=0x7fffffff;
    n=read();k=read();
    for(int i=1;i<=n;++i)
    {
        a[i]=read();
        if(k%a[i]==0&&k/a[i]<ans) ans=k/a[i];
    }
    write(ans);
    return 0;
}


#include <iostream>
#include <vector>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
#define::sync_with_stdio(false), cin.tie(0), cout.tie(0);

}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <climits>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <list>
#include <queue>
#include <string>
using namespace std;
#define x first
#define y second
#define mk make_pair
#define pb push_back
#define mid ((l+r) >> 1)
#define ls k<<1, l, mid
#define rs k<<1|1, mid+1, r
#define LS k<<1
#define RS k<<1|1
#define ll long long
#define lb long double
#define db double
#define PII pair<int,int>
#define For(i,a,b) for(int i = a;i <= b;i++)
#define Forn(i,a,b) for(int i = a;i >= b;i--)
inline int read(){
    int x = 0, f = 1;char ch = getchar();
    for (;ch < '0' || ch > '9';){if (ch == '-') f = -1;ch = getchar();}
    for (;ch >= '0' && ch <= '9';){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
int n,w;
#define N 1010
int a[N];
int flag[N],reflag[N];
int main(){
	n=read();
	For(i,1,n)a[i]=sread();
	Forn(i,n,1){
		if(reflag[a[i]]){
			flag[i]=1;
		}
		reflag[a[i]]=1;
	}
	int ans=0;For(i,1,n)if(!flag[i])ans++;
	printf("%d\n",ans);
	For(i,1,n)if(!flag[i])printf("%d ",a[i]);
}


#include <iostream>
#include <cstdio>

using namespace std;

int n, m, k, i, j, res(1);

void Init()
{
    cin >> n >> m >> k;
    m -= n;
    i = k; j = k;
    while (i > 1 || j < n)
     {
        //cout << i << " " << j << " " << m << endl;
        if (m >= j - i + 1)
        {
            m -= (j - i + 1);
            i--; j++; res++;
        }
        else break;
    }
    res += m / n;
    cout << res;
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    freopen("Div393B.inp", "r", stdin);
	  Init();
}
//Date 10 Month 2 Year 2017


#define maxn 505
#define ll long long
using namespace std;
const int mo=1e9+7;
int n,m,a[maxn],b[maxn],c[maxn],z[maxn],A[maxn],B[maxn];
ll K;
void inc(int &x,int y){x=((x+y>=mo)?x+y-mo:x+y);}
void dec(int &x,int y){x=((x-y<0)?x-y+mo:x-y);}
void mult(int *u,int *v){
    int i,j;
    memset(z,0,sizeof(z));
    for(i=0;i<250;i++)
        for(j=0;j<250;j++)
            z[i+j]=(z[i+j]+1LL*u[i]*v[j])%mo;
    for(i=498;i>=250;i--)
        for(j=1;j<=m;j++)
            inc(z[i-b[j]],z[i]);
    for(i=0;i<250;i++) u[i]=z[i];
}
void fpm(int *c,ll n){
    memset(A,0,sizeof(A));
    A[0]=1;
    while(n){
        if(n&1) mult(A,c);
        n>>=1,mult(c,c);
    }
}
int main(){
    int i,j;
    scanf("%d %d %lld",&n,&m,&K);
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    for(i=1;i<=m;i++) scanf("%d",&b[i]);
    for(i=1;i<=n;i++){
        memset(c,0,sizeof(c));
        c[1]=1,fpm(c,a[i]);
        for(j=0;j<250;j++) inc(B[j],A[j]);
    }
    fpm(B,K);
    for(i=0;i<250;i++) B[i]=A[i];
    for(i=249;i>0;i--)
        for(j=1;j<=m;j++)
            if(i>=b[j]) inc(B[i-b[j]],B[i]);
    cout<<B[0];
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=505,M=1e9+7;
int K,m,n,a[N],H[N],num[N],F[N],G[N],x,ans[N];
inline int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=x*x%M)
		if (y&1)(ans*=x)%=M;
	return ans;
}
inline void cf1(int A[]){
	int C[N];
	memset(C,0,sizeof C);
	for (int i=0;i<250;i++)
		for (int j=0;j<250;j++)(C[i+j]+=A[i]*A[j])%=M;
	int Inv=ksm(num[250],M-2);
	for (int i=499;i>=250;i--){
		int t=Inv*C[i]%M;
		for (int j=0;j<=250;j++)(C[250-j+i]+=M-t*num[j]%M)%=M;
	}
	for (int i=0;i<N;i++)A[i]=C[i];
}
inline void cf(int A[],int B[]){
	int C[N];
	memset(C,0,sizeof C);
	for (int i=0;i<250;i++)
		for (int j=0;j<250;j++)(C[i+j]+=A[i]*B[j])%=M;
	int Inv=ksm(num[250],M-2);
	for (int i=499;i>=250;i--){
		int t=Inv*C[i]%M;
		for (int j=0;j<=250;j++)(C[250-j+i]+=M-t*num[j]%M)%=M;
	}
	for (int i=0;i<N;i++)A[i]=C[i];
}
signed main(){
	scanf("%lld%lld%lld",&K,&m,&n);
	for (int i=1;i<=K;i++)scanf("%lld",&a[i]);
	while (m--){
		scanf("%lld",&x);
		(num[250-x]+=M-1)%=M;
	}
	num[250]++;
	ans[0]=1;
	for (int i=1;i<250;i++)
		for (int j=1;j<=i;j++)(ans[i]+=M-ans[i-j]*num[250-j]%M)%=M;
	for (int i=1;i<=K;i++){
		memset(F,0,sizeof F);
		memset(G,0,sizeof G);
		F[1]=1;int y=a[i];G[0]=1;
		for (;y;y>>=1,cf1(F))
			if (y&1)cf(G,F);
		for (int j=0;j<250;j++)(H[j]+=G[j])%=M;
	}
	memset(G,0,sizeof G);
	G[0]=1;
	for (;n;n>>=1,cf1(H))
		if (n&1)cf(G,H);
	int Ans=0;
	for (int i=0;i<250;i++)(Ans+=G[i]*ans[i])%=M;
	printf("%lld\n",Ans);
}


#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
using ll=long long;

ll phi_func(ll n){
	ll res=n;
	for(ll i=2LL;1LL*i*i<=n;i++){
		if(n%i==0){
			res=res/i*(i-1LL);
			while(n%i==0) n/=i;
		}
	}
	if(n!=1) res=res/n*(n-1);
	return res;
}

int main(void){
	ios::sync_with_stdio(false);
	cin.tie(0);

	ll n,k;
	cin >> n >> k;

	const ll num=(k+1)/2;

	while(--num){
		n=phi_func(n);
		if(n==1) break;
	}

	const ll mod=1000000007LL;
	n%=mod;
	cout << n << endl;

	return 0;
}


#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
#define M 1000007
char a[30];
int n,m,ans=0;bool b[M];
inline void Insert(int x,char y)
 {
 	int i,j,k,l,q,w,e=0;
 	for (i=0;i<x;i++)
 	  e=(e*39+a[i])%M;
 	e=(e*39+y)%M;
 	for (i=x;i<n;i++)
 	  e=(e*39+a[i]%M);
 	if (b[e]) return;
 	b[e]=1;ans++;
 	return;
 }
int main()
 {
    int i,j,k,l,q,w,e;
    scanf("%s",a);n=strlen(a);
    for (i=0;i<=n;i++)
     for (j='a';j<='z';j++)
       Insert(i,j);
    cout <<ans<<endl;
    return 0;
 }


#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 400009 /// I wanna be a marshmello
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll b,a,k;
    cin>>a>>b>>k;
    ll lcmt=2;
    rep(i,3,k+1){
        lcmt = (lcmt*i)/__gcd(lcmt,i);
    }

    /// first interval
    ll mult1=((b+lcmt-1)/lcmt)*lcmt;
    set<int> vis1;
    queue<pii> q;
    bool ch=0;
    ll ans1=0;
    ll dp[maxn];
        rep(i,0,maxn){
            dp[i]=INF;
        }
            dp[(mult1-1)%lcmt]=1;
            dp[0]=0;
            per(i,mult1,0){
                rep(j,2,k+1){
                    dp[(i/j)*j]=min(dp[i]+1,dp[(i/j)*j]);
                }
            dp[i]=min(dp[i],dp[i+1]+1);
    }
    ans1=dp[b%lcmt];
    /// third interval
    set<int> vis2;
    ll mult2 = ((a)/lcmt)*lcmt;
    ch=0;
    q.push({a,0});
    vis2.insert(a);
    ll ans2=0;
    while(!ch){
        auto e = q.front();
        // cout<<e.F<<endl;
        q.pop();
        if(e.F==mult2){
            ch=true;
            ans2=e.S;
            continue;
        }
        rep(i,2,k+1){
            if(((e.F)/i)*i!=e.F && vis2.find(((e.F)/i)*i!=e.F)==vis2.end()){
                q.push({((e.F)/i)*i,e.S+1});
                vis2.insert(((e.F)/i)*i);
            }
        }
    }
    while(!q.empty())q.pop();

    /// second interval
    rep(i,0,maxn){
        dp[i]=INF;
    }
    dp[lcmt-1]=0;
    per(i,lcmt,0){
        rep(j,2,k+1){
            dp[(i/j)*j]=min(dp[i]+1,dp[(i/j)*j]);
        }
        dp[i]=min(dp[i],dp[i+1]+1);
    }

    if(b/lcmt!=a/lcmt){
        // cout<<ans1+1<<" "<<ans2<<'\n';
        cout<<(dp[0]+1)*(mult2/lcmt-mult1/lcmt)+ans1+ans2<<'\n';
    }
    else{
        rep(i,0,maxn){
            dp[i]=INF;
        }
            dp[a%lcmt]=0;
            per(i,a%lcmt+1,0){
                rep(j,2,k+1){
                    dp[(i/j)*j]=min(dp[i]+1,dp[(i/j)*j]);
                }
            dp[i]=min(dp[i],dp[i+1]+1);
        }
        cout<<dp[b%lcmt]<<'\n';
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll k;
const ll inf = 1LL<<30;
ll solve(ll a,ll b){
	if(b < a)return inf;
	if(a==b)return 0;
	ll ret = inf;
	for(int i=2;i<=k;i++){
		if(b%i)
		ret = min(ret, solve(a,b - b % i)+1);
	}
	ret = min(ret , solve(a,b-1)+1);
	return ret;
}

int main(){
	ll a,b,ans=0;
	cin>>b>>a>>k;
	ll v1 = b%k;
	if(b - v1 >= a){
		b-=v1;
		ans++;
		ll diff = b-a;
		ll op = diff / k;
		if(op > 5)op-=3;
		ans += op * 2;
		b -= op * k;
	}
	ans += solve(a,b);
	cout<<ans<<endl;
}


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

#define lli long long int
#define ll long long
#define rep(i, a, b) for (int i = a; i < b; i++)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define mod 1000000007
#define inf 1e18
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define bakchodi                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

//prime sieve
vector<bool> primes(100006, false);
void sieve()
{
    for (ll i = 3; i <= 100006; i += 2)
    {
        primes[i] = 1;
    }
    //Sieve
    for (ll i = 3; i <= 100006; i+=2)
    {
        if (primes[i] == 1)
        {
            for (ll j = i * i; j <= 100006; j += i)
            {
                primes[j] = 0;
            }
        }
    }
    primes[2] = 1;
    primes[0] = primes[1] = 0;

}

int recpow(int x, int n)
{
    if (n == 0)
        return 1;
    else if (n % 2 == 0) //n is even
        return recpow((x * x), n / 2);
    else //n is odd
        return (x * recpow((x * x), (n - 1) / 2));
}

int main()
{
    bakchodi;
    int a,b,c;
    cin>>a>>b>>c;
    int k = b*c;
    int r = a*c;
    int ans = ceilc(float(r-k)/b);
    cout<<ans;

}


#include<iostream>
using namespace std;
int main ()
{int n,v[100],i,j,p,nr,x,nr1;
cin>>n;
for(i=1;i<=n;i++)
{cin>>v[i];
while(x!=v[i])
{ x=x*p+j;
p=p*10;
nr++;
nr1++;
if(nr==4)
{j++;
nr=0;}}
    cout<<nr1<<endl;
}
return 0;}


#include<cstdio>
#include<cmath>
#include<algorithm>
#define N 35
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
#define rf(i,a,b) for(register int i=(a);i>=(b);i=~(-i))
int dp[N][N][2],sum[N][2],n,m,mod=1e9+7,fac[N],ifac[N],lim[N],pow2[N],ans;
int spow(int m,int n)
{
	int b=1;
	for(;n;n>>=1,m=1ll*m*m%mod)if(n&1)b=1ll*b*m%mod;
	return b;
}
int C(int n,int m){return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
int ADD(int x,int y){return (x+=y)>=mod?x-mod:x;}
void init()
{
	fac[0]=ifac[0]=1,pow2[0]=1;
	f(i,1,32)fac[i]=1ll*fac[i-1]*i%mod,pow2[i]=2ll*pow2[i-1]%mod;
	ifac[32]=spow(fac[32],mod-2);
	rf(i,31,1)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	f(i,1,32)
	 f(j,0,i)
	  sum[i][j&1]=ADD(sum[i][j&1],C(i,j));
	while(n)lim[++m]=n&1,n>>=1;
	std::reverse(lim+1,lim+m+1);
}
int main()
{
	scanf("%d",&n);
	init();
	dp[0][0][1]=1;
	f(i,1,m)dp[i][0][0]=1;//如果该位填第一个向量，那也算一种方案
	f(i,1,m)
		f(j,1,i)//create a new unlimited state stands iff this is 1 and we make it 0
		{
			dp[i][j][0]=ADD(1ll*dp[i-1][j][0]*pow2[j]%mod,dp[i-1][j-1][0]);//no limit, or fill and last unlimited
			if(lim[i])
			{
				dp[i][j][0]=ADD(dp[i][j][0],1ll*dp[i-1][j][1]*sum[j][0]%mod);//make it!
				dp[i][j][1]=ADD(dp[i-1][j-1][1],1ll*dp[i-1][j][1]*sum[j][1]%mod);//limited, fill/unfill a vector
			}
			else dp[i][j][1]=1ll*dp[i-1][j][1]*sum[j][0]%mod;//cannot fill a vector
			/*
			   i j 0 <- (i-1 j 1 & make it 0) | (i-1 j 0 & forall) | (i-1 j-1 0)
			   i j 1 <- (i-1 j 1 & make it fit the num) | (i-1 j-1 1)
			*/
		}
	f(i,0,m)ans=ADD(ans,ADD(dp[m][i][0],dp[m][i][1]));
	return printf("%d\n",ADD(ans,mod)),0;


#include <bits/stdc++.h>
#include <algorithm>
#define ll long long

using namespace std;

map<string, int> times;

void brute(int size, int currSize, string currString, string toCheck) {

	if (currSize == size) {
		//cout << currString << endl;
		return;
	}

	if (currString != "") {
		int nPos = toCheck.find(currString, 0);
		int count = 0;
		while (nPos != string::npos)
		{
			count++;
			nPos = toCheck.find(currString, nPos + currString.size());
		}

		times[currString] = count;
	}

	brute(size, currSize + 1, currString + "4", toCheck);
	brute(size, currSize + 1, currString + "7", toCheck);
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;

	cin >> s;

	brute(s.size(), 0, "", s);

	int mostOccur = -1;
	string mostOccurVal = "";

	for (auto x : times) {
		if (x.second > mostOccur && x.second > 0) {
			mostOccur = x.second;
			mostOccurVal = x.first;
		}
	}

	if (mostOccur == -1) {
		cout << mostOccur << endl;
	}
	else {
		cout << mostOccurVal << endl;
	}

	return 0;
}


# include <cstdio>
# include <iostream>
# include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 200005;
int n;
ll val[maxn], ans[maxn], id[maxn], le1[maxn], le2[maxn], ri1[maxn], ri2[maxn];
struct no
{
	ll maxx;
	ll minn;
	ll sum;
	ll flag;
}node[maxn * 4];

void pushup(int root)
{
	node[root].maxx = max(node[root << 1].maxx, node[(root << 1)| 1].maxx);
	node[root].minn = min(node[root << 1].minn, node[(root << 1) | 1].minn);
	node[root].sum = node[root << 1].sum + node[(root << 1) | 1].sum;
}

void pushdown(int root, int le, int ri)
{
	int mid = (le + ri) >> 1;
	if (node[root].flag)
	{
		node[root << 1].flag = node[root << 1].maxx = node[root << 1].minn = node[root].flag;
		node[(root << 1) | 1].flag = node[(root << 1) | 1].maxx = node[(root << 1) | 1].minn = node[root].flag;
		node[root << 1].sum = node[root << 1].flag*(mid - le + 1);
		node[(root << 1) | 1].sum = node[(root << 1) | 1].flag*(ri - mid);
		node[root].flag = 0;
	}
}

void build(int root, int le, int ri)
{
	node[root].flag = 0;
	if (le == ri)
	{
		node[root].maxx = node[root].minn = node[root].sum = le;
		return;
	}
	int mid = (le + ri) >> 1;
	build(root << 1, le, mid);
	build((root << 1) | 1, mid + 1, ri);
	pushup(root);
}

void update(int oper_le, int oper_ri, int val, int le, int ri, int root)
{
	if (oper_le > oper_ri)
		return;
	if (node[root].minn >= val)
		return;
	if (oper_le <= le&&ri <= oper_ri&&node[root].maxx <= val)
	{
		node[root].flag = node[root].maxx = node[root].minn = val;
		node[root].sum = ll(ri - le + 1)*val;
		return;
	}
	pushdown(root, le, ri);
	int mid = (le + ri) >> 1;
	if (oper_le <= mid)
	{
		update(oper_le, oper_ri, val, le, mid, root << 1);
	}
	if (oper_ri > mid)
	{
		update(oper_le, oper_ri, val, mid + 1, ri, (root << 1) | 1);
	}
	pushup(root);
}
void solve()
{
	int i, j, k; cin>>n;
	memset(id, 0, sizeof(id));
	for ( int i = 1;i <= n;i++ )
	{
		cin>>val[i];
		id[val[i]] = i;
	}
	for (i = 1; i <= 200000; i++)
	{
		for (j = i; j <= 200000; j += i)
		{
			if (id[j])
			{
				if (le1[i] == 0 || id[j] < le1[i])
				{
					le2[i] = le1[i];
					le1[i] = id[j];
				}
				else if (le2[i] == 0 || id[j] < le2[i])
				{
					le2[i] = id[j];
				}
				if (ri1[i] == 0 || id[j] > ri1[i])
				{
					ri2[i] = ri1[i];
					ri1[i] = id[j];
				}
				else if (ri2[i] == 0 || id[j] > ri2[i])
				{
					ri2[i] = id[j];
				}
			}
		}
	}
	build(1, 1, n);
	for (i = 200000; i >= 1; i--)
	{
		if (le1[i] != ri1[i])
		{
			update(1, le1[i], ri2[i], 1, n, 1);
			update(le1[i] + 1, le2[i], ri1[i], 1, n, 1);
			update(le2[i] + 1, n, n + 1, 1, n, 1);
		}
		ans[i] = 1LL*n*(n + 1) - node[1].sum;
	}
	ll res = 0;
	for (i = 200000 - 1; i >= 1; i--)
	{
		res = res + 1LL*(ans[i + 1] - ans[i])*i;
	}
	printf("%I64d", res);
}
int main(void)
{
	solve();
	return 0;


#include <bits/stdc++.h>

using namespace std;

int main(){
    String x;
    Cin>>x;
    if(x[0]=='a'||x[0]=='h')
        Cout<<3<<endl;
    else if(x[1]=='1'||x[1]=='8')
        Cout<<5<<endl;
    else
        Cout<<8<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
char c;
int k;
int main() {
	scanf("%c%d",&c,&k);
	int ans=8;
	if(c-'0'==1||c-'0'==8) ans-=3;
	if(k==1||k==8) ans-=3;
	if((k==1||k==8)&&(c-'0'==1||c-'0'==8) ans++;
	printf("%d",ans);
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,m,z,x,i,p;
    vector<int>v;
    cin>>n>>m;
    while(n<m)
    {
        v.push_back(n);
        n=n*2;
    }
    z=0;
    while(n%m!=0)
    {
        x=n%m;
        p=sizeof(v);
        z=0;
        for(i=0;i<p;i++)
        {
            if(x==v[i])
            {
                z=1;
                break;
            }
        }
        if(z==1)
        {
            cout<<"No";
            break;
        }
        v.push_back(x);
        n=n+x;
    }
    if(z==0)
        cout<<"Yes";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> v;
    int H[100]={0};
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(H[x]==0){
            v.push_back(x);
            H[x]++;
        }
    }
    sort(v.begin(),v.end());
    int mindiff=100;
    if(v.size()>=2)
    for(int i=0;i<v.size()-1;i++){
        if(mindiff>v[i+1]-v[i])
            mindiff=v[i+1]-v[i];
    }
    else
        mindiff = v[0];
    cout<<mindiff*n;
}


//its not how good you are...its how good you want to be
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll  long long  int
#define inf 1000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define ld  long double

ll x[25],y[25],a[25],n,l,r;
ld dp[1<<20+5],limit;
ld pi=acos(-1.0l),eps=1e-61;

ld func(ld dist,ll id)
{
	ld ax=x[id]-(l+dist);
	ld ay=y[id];
	ld len=sqrt(ax*ax+ay*ay);
	ld angle=acos(1.0*ax/len);
	ld given=a[id]/180.0*pi;
	ld third=pi-angle-given;
	if(third<eps)
	return limit;
	ld distance=sin(given)*len/sin(third);
	return min(dist+distance,limit);
}
int main()
{
	boost1;boost2;
	cout<<fixed<<setprecision(10);
	ll i,j,mask;
	cin>>n>>l>>r;
	limit=r-l;
	for(i=0;i<n;i++)
	cin>>x[i]>>y[i]>>a[i];
	dp[0]=0.0;
	for(mask=1;mask<(1<<n);mask++)
	{
		for(i=0;i<n;i++)
		{
			if(mask&(1<<i))
			dp[mask]=max(dp[mask],func(dp[(mask^(1<<i))],i));
		}
	}
	cout<<dp[(1<<n)-1];
    return 0;
}


//TO CAHNGE THE WORLD
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define L first
#define R second
#define int ll
typedef long long ll;

const int maxn=1e6+10, inf=1e9+10;

int grid[maxn][40], a, b, n, sett[maxn][40];
int pow(int x, int n)
{
    if(n==0) return 1;
    if(n==1) return x;
    int p=pow(x,n/2);
    if(n%2==1) return min(p*p*x,inf);
    else return min(p*p,inf);
}
int px[2]={0,-1};
int py[2]={-1,0};
queue<pair<int, int> > q;
bool mark[maxn][40];
//1-> win 2-> lose 0->draw
 main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin>>a>>b>>n;
    if(pow(a,b)>=n) return cout<<"Stas", 0;
    for(int i=1; i<maxn; i++)
    {
	for(int j=1; j<40; j++)
	    if(pow(i,j)>=n) grid[i][j]=1, mark[i][j]=1, q.push(mp(i,j));
    }
    if(n>=maxn)
    {
	mark[maxn-1][1]=1;q.push(mp(maxn-1,1));
	if((maxn-1)%2==n%2) grid[maxn-1][1]=1;
	else grid[maxn-1][1]=2;
    }
    while(q.size())
    {
	auto cur=q.front();q.pop();
	int i=cur.L, j=cur.R;
	if(grid[i][j]==2)
	{
	    for(int k=0; k<2; k++)
	    {
		int x=i+px[k], y=j+py[k];
		if(x && y && x<maxn && y<40) if(!mark[x][y]) grid[x][y]=1, sett[x][y]++, mark[x][y]=1, q.push(mp(x,y));
	    }
	}
	else
	{
	    for(int k=0; k<2; k++)
	    {
		int x=i+px[k], y=j+py[k];
		if(x&&y&&x<maxn&&y<40)
		{
		    sett[x][y]++;
		    if(!mark[x][y] && sett[x][y]==2)
			grid[x][y]=2, mark[x][y]=1, q.push(mp(x,y));
		}
	    }
	}
    }
    if(grid[a][b]==0) return cout<<"Missing", 0;
    if(grid[a][b]==1) return cout<<"Masha", 0;
    if(grid[a][b]==2) return cout<<"Stas", 0;
}


#include <iostream>

using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int l=s.length();
    if(l==1){
        cout<<"0";
    }
    else{
            if(s[0]!='1'){
                s[0]='1';
                k--;
            }
        for(int i=0;i<k;i++){
            int x=1;
            while(1){
                if(s[i+x]!='0'){
                    break;
                }
                x++;
            }
            s[i+x]='0';
        }
        cout<<s;
    }
    return 0;
}


#include <iostream>
#include <map>

using namespace std;

//int main_Coins(){
int main(){

	map<char, int> m;
	int n = 0;
	char c[4];
	m['A']=0;
	m['B'] =0;
	m['C'] =0;
	while(1==1)
	{
		for(int i =0; i<3; i++)
		{
			scanf("%s",&c);
			if(c[1] == '>'){
				m[c[0]]++;
			}
			else {
				m[c[2]]++;
			}
		}
		if (m['A']==1 && m['B']==1 && m['C'] ==1)
			printf("Impossible");
		else
		{
			for(int i=0; i<3; i++){
				for(int j=0; j<3; j++){
					if(m['A'+j] == i) printf("%c",'A'+j);
				}
			}

			printf("\n");
		}

	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

template<typename T, typename C = T>
struct min_cost_flow
{
	struct edge
	{
		int src, dst;
		T cap, flow;
		C cost;
		int rev;
	};

	int n;
	vector<vector<edge>> adj;

	min_cost_flow(int n) : n(n), adj(n) {}

	void add_edge(int src, int dst, T cap, C cost)
	{
		adj[src].push_back({ src, dst, cap, 0, cost, (int) adj[dst].size() });
		if (src == dst)
			adj[src].back().rev++;
		adj[dst].push_back({ dst, src, 0, 0, -cost, (int) adj[src].size() - 1 });
	}

	const C oo = numeric_limits<C>::max();

	vector<C> dist, pot;
	vector<edge*> prev;

	bool dijkstra(int s, int t)
	{
		dist.assign(n, oo);
		prev.assign(n, nullptr);
		dist[s] = 0;

		using pci = pair<C, int>;
		priority_queue<pci, vector<pci>, greater<pci>> pq;
		pq.push({ 0, s });

		while (!pq.empty())
		{
			C d; int u;
			tie(d, u) = pq.top();
			pq.pop();

			if (d != dist[u])
				continue;

			for (auto &e : adj[u])
				if (e.flow < e.cap
						&& dist[e.dst] > dist[u] + e.cost + pot[u] - pot[e.dst])
				{
					dist[e.dst] = dist[u] + e.cost + pot[u] - pot[e.dst];
					prev[e.dst] = &e;
					pq.push({ dist[e.dst], e.dst });
				}
		}

		return dist[t] < oo;
	}

	pair<T, C> max_flow(int s, int t)
	{
		T flow = 0;
		C cost = 0;

		pot.assign(n, 0);
		while (dijkstra(s, t))
		{
			for (int u = 0; u < n; ++u)
				if (dist[u] < oo)
					pot[u] += dist[u];

			T delta = numeric_limits<T>::max();
			for (edge *e = prev[t]; e != nullptr; e = prev[e->src])
				delta = min(delta, e->cap - e->flow);

			flow += delta;
			for (edge *e = prev[t]; e != nullptr; e = prev[e->src])
			{
				e->flow += delta;
				adj[e->dst][e->rev].flow -= delta;
				cost += delta * e->cost;
			}
		}

		return {flow, cost};
	}
};

int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m, k, c, d;
	cin >> n >> m >> k >> c >> d;
	vector<int> mk(n+1);
	for (int i = 0, x; i < k; ++i)
		cin >> x, ++mk[x];

	int sink = (k+1)*n*n+1;
	min_cost_flow<int, int> mcf(sink+1);

	for (int i = 0, u, v; i < m; ++i)
	{
		cin >> u >> v;
		for (int t = 0; t < k*n; ++t)
			for (int j = 1; j <= 1+2*k; j += 2)
			{
				mcf.add_edge(t*n+u, (t+1)*n+v, 1, j*d+c);
				mcf.add_edge(t*n+v, (t+1)*n+u, 1, j*d+c);
			}
	}

	for (int t = 0; t < k*n; ++t)
		for (int j = 1; j <= n; ++j)
			mcf.add_edge(t*n+j, (t+1)*n+j, k, c);

	for (int t = 0; t <= k*n; ++t)
		mcf.add_edge(t*n+1, sink, k, 0);

	for (int i = 1; i <= n; ++i)
		if (mk[i] > 0)
			mcf.add_edge(0, i, mk[i], 0);

	cout << mcf.max_flow(0, sink).S << "\n";

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <memory.h>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
const int N = 1005;
const int mod = 1e9 + 7;
int bin_pow(int a, int n){
    int res = 1;
    while(n){
        if(n & 1) res = (res * 1ll * a) % mod;
        n >>= 1;
        a = (a * 1ll * a) % mod;
    }
    return res;
}
int inv(int a){
    return bin_pow(a, mod - 2);
}
void add(int & a, int & b, int & c, int & d){
    int cur1 = (a * 1ll * d + b * 1ll * c) % mod;
    int cur2 = (b * 1ll * d) % mod;
    a = cur1;
    b = cur2;
}
queue<pair< pair<int, int >, pair <int, int> > > q;
int main(){
    int k, pa, pb;
    cin >> k >> pa >> pb;
    q.push({ {1, 0}, {1, 1} });
    int ans_a = k;
    int ans_b = 1;
    while(!q.empty()){
        auto tmp = q.front();
        q.pop();
        int cnt_a = tmp.first.first;
        int cnt_seq = tmp.first.second;
        int a = tmp.second.first;
        int b = tmp.second.second;
        if(cnt_a + cnt_seq >= k){
            int cur = cnt_a + cnt_seq - k;
            int aa = (pb * 1ll * cur + pa) % mod;
            int bb = pb;
            a = (a * 1ll * aa) % mod;
            b = (b * 1ll * bb) % mod;
            add(ans_a, ans_b, a, b);
        }
        else{
            q.push({{cnt_a + 1, cnt_seq}, {(a * 1ll * pa % mod), (b * 1ll * (pa + pb) % mod)}});
            q.push({{cnt_a, cnt_seq + cnt_a}, {(a * 1ll * pb % mod), (b * 1ll * (pa + pb) % mod)}});
        }
    }
    int ans = (ans_a * 1ll * inv(ans_b)) % mod;
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair < ll,ll > pll;
#define MAX 20000007
#define INF INT_MAX
ll n,x,y;
int d[MAX];

ll sp(){
	// priority_queue< pll,vector < pll >, greater < pll > > pq;
	set< pll > s;
	s.insert(pll(0,0));
	while(!s.empty()){
		pll t=*s.begin();
		s.erase(s.begin());
		if(t.second == n)return t.first;
		if(t.second >= 2 && d[t.second-1] > t.first+x) {
			if(s.find(pll(d[t.second-1],t.second-1))!=s.end())s.erase(s.find(pll(d[t.second-1],t.second-1)));
			// pq.push(pll(t.first+x,t.second-1));
			d[t.second-1]=t.first+x;
			s.insert(pll(d[t.second-1],t.second-1));
		}
		if(t.second < n && d[t.second+1] > t.first+x){
			if(s.find(pll(d[t.second+1],t.second+1))!=s.end())s.erase(s.find(pll(d[t.second+1],t.second+1)));
			// pq.push(pll(t.first+x,t.second+1));
			d[t.second+1]=t.first+x;
			s.insert(pll(d[t.second+1],t.second+1));
		}
		if(t.second < n && d[t.second << 1] > t.first+y){
			if(s.find(pll(d[t.second << 1],t.second << 1))!=s.end())s.erase(s.find(pll(d[t.second << 1],t.second << 1)));
			// pq.push(pll(t.first+y,t.second << 1));
			d[t.second << 1]=t.first+y;
			s.insert(pll(d[t.second << 1],t.second << 1));
		}
	}
}

int main(){
	scanf("%lld %lld %lld",&n,&x,&y);
	fill(d,d+MAX,INF);
	printf("%lld\n",sp());
}


#include <iostream>
using namespace std ;
int main() {
  int m ;
  int n ;
  int area ;
   cin >>m >>n>>area ;
   int s = m*n ;
   int number = s/area ;
   cout <<number ;

  return 0;
}


#include<stdio.h>
#include<algorithm>
#include<vector>
const int mod = 1000000007;
void solve(int n){
    long long int a[100000000], d[100000000];
    int i;
    a[1]=1;
    d[1] = 0;

    for (i=2;i<n+1;i++){
        d[i] = (d[i - 1] * 3)%mod;
        a[i] = (a[i - 1] * 2 + d[i - 1])%mod;
    }
    printf("%I64d", d[n] % mod);
}
int main(){
    #pragma comment(linker,"/STACK:67108864")
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif
    int n, m, k;
    while (scanf("%d", &n) != EOF){
        solve(n);
    }
    return 0;
}


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

int main(){
    int n,k,i,count,cutoff;
    cin >> n>>k;
    string s;
    int nums[n];

    i = 0 ;
    while(i<n){
        cin >> nums[i];
        i++;
    }
    i = 0;
    count = 0;
    cutoff = nums[k-1];
    if(cutoff == 0){
        cout<<0;
    }
    else{
        while(i < n){
            if(nums[i] >= cutoff){
                count++;
            }
            else{
                break;
                }

        }
        cout<<count;
    }
}


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

typedef long long ll;
const int MAXN = 2e5 + 5;
const long long MOD = 1e9 + 7;

pair<int,int> p;

int main()
{
	//freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);

	int n,k; cin >> n >> k;
	string s; cin >> s;
	int c1 = 0; int c2 = 0;
	for(int i = 0; i < n;)
	{
		if(s[i] == 'N')
		{
			int j = i;
			while(j < n && s[j] == 'N')
				j++;
			c1 = max(c1,j - i);
			i = j;
		}
		else
		{
			i++;
		}
	}
	for(int i = 0; i < n;)
	{
		if(s[i] == 'N' || s[i] == '?')
		{
			int j = i;
			while(j < n && (s[j] == 'N' || s[j] == '?'))
				j++;
			c2 = max(c2,j - i);
			i = j;
		}
		else
		{
			i++;
		}
	}
	if(c1 > k || c2 < k){
		cout << "NO";
		return 0;
	}

	for(int i = 0; i < n; ++i)
	{
		for(int j = i; j < n; ++j)
		{
			if(j - i + 1 !=  k) continue;
			else if()
			{
				int c = 0;
				for(int l = i; l <= j; ++l)
				{
					if(s[l] == '?' || s[l] == 'N')
						c++;
				}
				if(c == k){
					int fl = 1;
					if(i - 1 >= 0 && s[i - 1] == 'N') fl = 0;
					if(j + 1 < n && s[j + 1] == 'N') fl = 0;
					if(fl)
					{
						cout << "YES\n";
						return 0;
					}
				}
			}
		}
	}
	cout << "NO";

	return 0;

}


#include <bits/stdc++.h>
using namespace std;
long long n,m,a,b,i,s[505][505],vis[505],c[505],j,d,e;
string t;
vector < long long > v[300000];
vector < pair < long long,long long > > v1;
void dfs(long long x)
{
    vis[x]=1;
    for(long long i=0;i<v[x].size();i++)
    {
        if(!vis[v[x][i]])
        {
            if(c[x]==1)
            {
                c[v[x][i]]=2;
            }
            else
            {
                c[v[x][i]]=1;
            }
            dfs(v[x][i]);
        }
        else
        {
            if(c[v[x][i]]==c[x])
            {
                cout << "NO";
                exit(0);
            }
        }
    }
}
int main()
{
    cin >> n >> m;
    for(i=1;i<=m;i++)
    {
        cin >> a >> b;
        v1.push_back(make_pair(a,b));
        v1.push_back(make_pair(b,a));
        s[a][b]=1;
        s[b][a]=1;
    }
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            if(!s[i][j])
            {
                v[i].push_back(j);
                v[j].push_back(i);
            }
        }
    }
    for(i=1;i<=n;i++)
    {
        if(!vis[i] && v[i].size()>0)
        {
            c[i]=1;
            dfs(i);
        }
    }
    for(i=1;i<=n;i++)
    {
        if(c[i]!=0)
        {
            if(c[i]==1)
            {
                t[i]='a';
            }
            else
            {
                t[i]='c';
            }
        }
        else
        {
            t[i]='b';
        }
    }
    for(i=0;i<v1.size();i++)
    {
        d=v1[i].first;
        e=v1[i].second;
        if(t[d]=='a')
        {
            if(t[e]!='c')
                continue;
            else
            {
                cout << "NO";
                exit(0);
            }
        }
        else if(t[d]=='c')
        {
            if(t[e]!='a')
                continue;
            else
            {
                cout << "NO";
                exit(0);
            }
        }
    }
    cout << "YES" << endl;
    for(i=1;i<=n;i++)
    {
        cout << t[i];
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main ()
{
int n,d,m,money=0;
cin>>n>>d;
int *a=new int [n];
for (int i=0;i<n;i++)
cin>>a[i];
cin>>m;
sort(a,a+n);
for (int i=0;i<min(n,m);i++)#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main ()
{
int n,d,m,money=0;
cin>>n>>d;
int *a=new int [n];
for (int i=0;i<n;i++)
cin>>a[i];
cin>>m;
sort(a,a+n);
for (int i=0;i<min(n,m);i++)
money+=a[i];
if (m>n)
{money-=abs((m-(n))*d);cout<<money;}
else cout<<money;
return 0;
}
money+=a[i];
if (m>n)
money-=abs((m-(n))*d);
else cout<<money;
cout<<money;
return 0;
}


// 16
// I remember reading the editorial...
// should've already solved this by now.

#ifndef LOCAL
#define NDEBUG 1
#endif
#include<bits/stdc++.h>
#include<Modular.h>

using modular=Modular<1000000007>;

int main(){
	std::ios::sync_with_stdio(0);std::cin.tie(0);
	int number; std::cin>>number;
	//std::vector<std::vector<modular>> probability(number, std::vector<modular>(number));
	std::vector<modular> probability(number*number);
	//for(auto& row: probability)
	for(auto& value: probability){
		int percentage; std::cin>>percentage;
		value=modular(1)/100*percentage;
	}

	std::vector<modular> total;

	int const middle=number/2;
	auto const maskValue=[&]{
		std::array<int, 1<<6> maskValue;
		assert(number<=6);
		int count=0;
		for(int matchMask=0; matchMask<(int)maskValue.size(); ++matchMask){
			maskValue[matchMask]=__builtin_popcount(matchMask)==middle ? count++: -1;
		}
		total.resize(1<<count);
		return maskValue;
	}();

	auto const process=[&](int left, int right, auto handle){
		auto const len=right-left;
		for(int edgeMask=0; edgeMask<(1<<(len*number)); ++edgeMask){
			modular totalProbability=1;

			// inefficient
			for(int tmp=edgeMask, i=left*number; i<right*number; ++i, tmp>>=1){
				totalProbability*=tmp&1 ?  probability[i]: 1-probability[i];
				if(totalProbability==0) goto continue_outer_2;
			}

			{ // compute matchSets and call handle
				// even more inefficient...?
				std::array<char, 3> data{};
				assert(len<=(int)data.size());
				int matchSets{};
				while(true){
					// process data
					int matchMask{};
					for(int index=0; index<len; ++index){
						if(not(edgeMask>>(index*number+data[index])&1)) goto continue_outer;
						if(matchMask&1<<data[index]) goto continue_outer;
						matchMask|=1<<data[index];
					}
					if(right==number) // second half, should invert
						matchMask^=(1<<number)-1;

					matchSets|=1<<maskValue[matchMask];

continue_outer:
					// increase data
					for(int i=len-1;;){
						if(i<0) goto break_outer;
						if(data[i]==number-1){data[i]=0; --i;}
						else{++data[i]; break;}
					}
				}
break_outer:;

				handle(matchSets, totalProbability);
			}

continue_outer_2:;
		}
	};
	assert(middle<number);
	process(0, middle,[&](int sets, modular probability){
		total[sets]+=probability;
	});
	for(int dim=1; dim<(int)total.size(); dim<<=1)
		for(int i=0; i<(int)total.size(); ++i)
			if(not(i&dim))
				total[i|dim]+=total[i];

	modular result{};
	process(middle, number,[&](int sets, modular probability){
		result+=probability*(total.back()-total[(1<<number)-1-sets]);
	});
	std::cout<<(int)result<<'\n';

}


#include <bits/stdc++.h>

#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define all(c) (c).begin(), (c).end()

#define ll long long
#define vt vector
#define pb push_back
#define FOR(x) for(int i=0;i<x;i++)

using namespace std;

int main() {

    ios;

    int a,b,c,d,e,f,g,h,i;
    cin >> a >> b >> c;
    cin >> d >> e >> f;
    cin >> g >> h >> i;
    a = 1;
    int k = 1;
    while(k <= 17) {
        a=k;
        e=k;
        i=k;
        if(a+e+i==a+b+c&&a+e+i==g+h+i&&a+e+i==b+e+h) {
            cout << a << " " << b <<  " " << c << "\n";
            cout << d << " " << e <<  " " << f << "\n";
            cout << g << " " << h <<  " " << i << "\n";
            return 0;
        }
        k++;
    }
    while(true) {
        if(a+e+i==a+b+c&&a+e+i==g+h+i&&a+e+i==b+e+h) {
            break;
        }
        a++;
        if(a+e+i==a+b+c&&a+e+i==g+h+i&&a+e+i==b+e+h) {
            break;
        }
        e++;
        if(a+e+i==a+b+c&&a+e+i==g+h+i&&a+e+i==b+e+h) {
            break;
        }
        i++;
    }
    cout << a << " " << b <<  " " << c << "\n";
    cout << d << " " << e <<  " " << f << "\n";
    cout << g << " " << h <<  " " << i << "\n";
}


#include <iostream>
#include <cstring>
#include <vector>
typedef long long int ll;
using namespace std;
char temp[3000000];
int n;
vector<ll> st;
ll cal(ll len){
	ll sum = 1;
	for (ll i = 0; i < len; i++){
		sum *= 10;
	}
	return sum;
}
bool ispos(ll a){
	for (int i = 0; i < st.size(); i++){
		if (st[i] == a)
			return false;
	}
	st.push_back(a);
	return true;
}
int main(){
	cin >> n;
	char *ptr;
	for (int i = 0; i < n; i++){
		cin >> temp;
		ptr = strtok(temp, "'");
		ptr = strtok(NULL, "'");

		ll len = strlen(ptr);
		ll sum = cal(len);
		ll a = _atoi64(ptr);

		for (int k = 1; k <= a; k++){
			a = k;
			while (1)
			{

				a += sum;
				if (a >= 1989 && ispos(a))
					break;
			}
		}
		cout << a << endl;
	}

	return 0;
	//ptr = strtok(str, ",");
}


#include <iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#define ll long long

using namespace std;
ll ing[3],quan[3],price[3],total_amount;

bool chk(ll n)
{
    ll total_cost = 0;
   // cout<<"n: "<<n<<endl;
    for(int i=0; i<3; i++)
    {
       if(ing[i]!=0 && ing[i]*n >= quan[i])
       total_cost+=max((ll)0, (ing[i]*n - quan[i])*price[i] );
    }
    //cout<<n<<' '<<total_cost<<endl;
    if(total_cost<=total_amount) return true;
    else return false;
}

int main()
{
    //freopen("input.txt", "r",stdin);
    ll l = 0;
    ll u = 2e12;
    string str;
    cin>>str;
    cin>>quan[0]>>quan[1]>>quan[2];
    memset(ing,0,sizeof(ing));
    for(int i=0; i<str.size(); i++)
    {
        if(str[i]=='B') ing[0]++;
        else if(str[i]=='S') ing[1]++;
        else ing[2]++;
    }
    cin>>price[0]>>price[1]>>price[2];
    cin>>total_amount;
    ll mid;
    u = total_amount;
    if( chk(l)&&!chk(l+1)) { cout<<l; return 0; }
    while(l<=u)
    {
      mid = l + (u-l)/2;
      //cout<<l<<' '<<u<<' '<<mid<<endl;;

     // cout<<chk(mid)<<' '<<chk(mid+1)<<endl;
     // cin>>x;
      if(chk(mid)&&!chk(mid+1)) {cout<<mid<<endl; break;}
      else if(!chk(mid)&&chk(mid-1)) {cout<<mid-1<<endl; break;}
      else if(chk(mid)) l=mid;
      else u=mid-1;
    }
   // cout<<mid<<endl;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool verif(string x,string x1)
{
   int j=0;
 while (j+1<x.length())
    {
     string t=x.substr(j,2);
            if(t==x1)
            {
               return true;
            }
      j++;
    }
    return false;
}
int main()
{
    string mdp,tryy="";
    cin>>mdp;
    int a,j=0;
    cin>>a;
    vector <string> tab;
    tab.resize(a);
    for (int i=0;i<a;i++)
    {
        cin >> tab[i];

    }
    if (a==1)
    {
        for (int i=0;i<a;i++)
        {
            tryy=tab[0]+tab[0];
        }
        if (verif(tryy,mdp))
        {
            cout<<"YES";
            return 0;
        }
    }
     do
     {
      string  tryy="";
      for (int i=0;i<a;i++)
      {
          tryy+=tab[i];
          //cout <<tryy<<endl;
      }
      if (verif(tryy,mdp))
      {
          cout<<"YES";
          return 0;
      }
     }while(next_permutation(tab.begin(),tab.end()));
     cout<<"NO";
}


#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <sstream>
#include <string>
#include <map>
#include <functional>
#include <stack>
#include <fstream>
#include <ctype.h>
#include <queue>

using namespace std;

int main(void){

  int n;
  cin>>n;

  queue<char> q;

  q.push('S');
  q.push('L');
  q.push('P');
  q.push('R');
  q.push('H');

  int i;
  char x;
  for(i=0;i<n;i++){

    x = q.front();
    q.pop();
    q.push(x);
    q.push(x);

  }

  if(x == 'S') cout<<"Sheldon"<<endl;
  else if(x == 'L') cout<<"Leonard"<<endl;
  else if(x == 'P') cout<<"Penny"<<endl;
  else if(x == 'R') cout<<"Rajesh"<<endl;
  else if(x == 'H') cout<<"Howard"<<endl;

  return 0;

}


#include<iostream>
using namespace std;
int main ()
{
	int a,b,num=0,num1=0;
	cin>>a>>b;
	num=a/b;
   if(false)
   {
	   num=num+a;

	   cout<<num<<endl;
   }
   else
   {
	   while(b!=1)
	   {
		   b=num/b;
		   num1+=b;
	   }
	   cout<<num1+num+a<<endl;
   }

	return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int num;
    string c;
    cin >> num;
    cin >> c;
    int g,m,i,k,l[50]={ };
    i=0;
    k=0;
    m=c.length();
    while(i<m){
        if(c[i]=='W')
        i++;
        else if(c[i]=='B'){
            k++;
            while(c[i]=='B'){
                l[k-1]++;
                i++;
            }
        }
    }
    cout << k << endl;
    if (k>0) cout << l[0];
    i=1;
    while(i<k){
        cout << " " <<l[i];
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double pi=3.14159265359;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n,m,i,j,l,k=2,p=0,t=1,x,y,z,r,c;
    ll a[100005]={0};
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        k=s[i];
        a[k]++;
        for(i=k-1;i>=97;i--)
        {
            if(a[i]==0)
            {
                cout<<"NO";
                return 0;
            }
        }
    }
    cout<<"YES";
    return 0;
}


//Pham Huu Canh
//C. Kicker

#include<iostream>
#include<fstream>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define max64 9223372036854775807
#define max32 2147483647
#define max16 32767
#define EPS 1e-8
#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PQ priority_queue
#define timmax(x, y) ((x) > (y) ? (x) : (y))
#define timmin(x, y) ((x) < (y) ? (x) : (y))

#define fi "C.inp"
#define fo "C.out"

using namespace std;

int a[5], b[5];

int ktra(int x, int y)
{
    int thu = a[x];
    int cong = b[y];

    if (thu < b[2] && cong < a[3])  return -1;
    if (thu < b[3] && cong < a[2])  return -1;
    if ((thu > b[2] && cong > a[3]) && (thu > b[3] && cong > a[2])) return 1;
    return 0;
}

void input()
{
    int i, kq1, kq2;

    for (i = 0; i < 4; i++)
        scanf("%d %d", &a[i], &b[i]);   //def, attack

    kq1 = ktra(0, 1);
    kq2 = ktra(1, 0);
    if (kq1 == 1 || kq2 == 1)
        printf("Team 1\n");
    else if (kq1 == 0 && kq2 == 0)
        printf("Draw\n");
    else
        printf("Team 2\n");
}

int main()
{
    //freopen(fi,"r",stdin);
    //freopen(fo,"w",stdout);

    input();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=5e5+5;
const int mod=998244353;

ll n,k,f[N],inv[N];
void pre(){
    f[0]=1;
    rep(i,1,5e5) f[i]=f[i-1]*i%mod;
    inv[int(5e5)]=235551727;
    repb(i,5e5-1,0) inv[i]=(i+1)*inv[i+1]%mod;
}
signed main(){
    FastIO;
    pre();
    cin>>n>>k;
    ll ans=0;
    rep(i,1,n) if(n/i>=k){
        ans=(ans+f[n/i-1]*inv[k-1]%mod*inv[n/i-k])%mod;
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    int a,x,y;
    cin>>a;
    while(1)
    {
    cin>>x>>y;
    if(abs(x)>a || y<0 || y>(5*a) || (abs(x)%a==0 && x!=0) || y%a==0)
        cout<<-1<<endl;
    else
    {
        if(y<(2*a))
        {
            if(abs(x)<(a/2.0))
                cout<<(int)(y/a)+1<<endl;
            else
                cout<<-1<<endl;
        }
        else if(y<(3*a))
        {
            if(x==0)
            cout<<-1<<endl;
            else if(x<0)
                cout<<3<<endl;
            else
                cout<<4<<endl;
        }
        else if(y<4*a)
        {
            if(abs(x)<(a/2.0))
                cout<<5<<endl;
            else
                cout<<-1<<endl;
        }
        else
        {
            if(x==0)
            cout<<-1<<endl;
            else if(x<0)
                cout<<6<<endl;
            else
                cout<<7<<endl;
        }
    }
    }
    return 0;
}


#include <bits/stdc++.h>

#ifdef LOCAL_TEST
  #pragma comment(linker, "/stack:16777216")
#endif

using namespace std;

typedef long long int ll;
typedef vector <ll> vll;
typedef pair<ll, ll> pp;
typedef vector<pp > vpp;
typedef vector <int> vi;
typedef stack <int>  si;
typedef stack <ll> sll;
typedef stack < pair<int, int> > sii;
typedef queue < pair<int, int> > qii;

#define sz(a) (ll) ((a).size())
#define pb push_back
#define mp(a, b)       (make_pair(a, b) )
#define all(c)        (c).begin(),(c).end()
#define tr(c,i)       for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)  ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sortA(v)      (sort(v.begin(), v.end()))
#define sortD(v)      (sort(v.rbegin(), v.rend()))
#define fill(a)       (memset(a, 0, sizeof (a)))
#define fillA(a)       (memset(a, -1, sizeof (a)))
#define end '\n'
#define PI 3.14159265

const int MAX = 100009;
const ll MOD = 1e9 + 7;
#define _  %  MOD
#define __ %= MOD

// Functions
ll gcd(ll a, ll b){
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}
ll abs(ll a, ll b){
  if( a > b)
    return a-b;

  return b-a;
}
double abs(double a, double b){
  if( a > b)
    return a-b;

  return b-a;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifdef LOCAL_TEST
		  ifstream cin("in.txt"); ofstream cout("out.txt");
    #endif

    ll r,g; cin>>r>>g;
    r=r+g;
    g=r-g;
    r=r-g;

    ll n, d[200010] = {0};
    for (n = 0; n < 600; n++) {
        if(n*(n+1) > 2*(r+g))
        {
          break;
        }
    } n--;

    d[0] = 1;
    for (ll i = 1; i <= n; i++) {
      ll sum=(i*(i+1))/2;

      for (ll j = r; j >= 0; j--) {
        if(sum > j+g)
        {
          d[j] = 0;
        }
        else if( j - i >= 0)
        {
          d[j] += d[j-i];
          d[j] __;
        }
      }
    }

    ll ans = 0;

    for (ll i = 0; i <= r; i++) {
      ans += d[i];
      ans __;
    }

    cout<<ans<<end;

    return 0;
}


// Wanna Hack? GL...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=1e5+10,mod=1e9+7;
const ll inf=1e18;

int n;
set<int>st;

int lca(int a,int b){
    if(__builtin_clz(a)>__builtin_clz(b)) swap(a,b);
    while(__builtin_clz(a)<__builtin_clz(b)) a>>=1;
    while(a!=b) a>>=1,b>>=1;
    return a;
}
inline bool papa(int a,int b){// a!=b
    if(b<=a) return 0;
    int dif=__builtin_clz(a)-__builtin_clz(b);
    return a==(b>>dif);
}
int Size(int a){
    int x=1,ans=0;
    while(a<=n){
	ans+=min(x,n-a+1);
	x<<=1,a<<=1;
    }
    return ans;
}
int Size(int a,set<int>s){
    int ans=Size(a);
    vector<int>vv;
    for(int x:s){
	if(x<a) continue;
	bool bl1=papa(a,x),bl2=0;
	for(int y:vv) bl2|=papa(y,x);
	if(bl1 && !bl2) vv.PB(x),ans-=Size(x);
    }
    return ans;
}
int solve(int a,int b){
    int ans=0;
    for(int A=a;A>0;A>>=1){
	set<int>st2=st;
	for(int B=b;B>0;B>>=1){
	    ans=(1ll*ans+1ll*Size(A,st2)*Size(B,st2))%mod;
	    if(st2.count(B>>1)) break;
	    st2.insert(B>>1);
	}
	if(st.count(A>>1)) break;
	st.insert(A>>1);
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int m;cin>>n>>m;
    vector<pii>vv(m),vv2;
    for(int i=0;i<m;i++){
	cin>>vv[i].F>>vv[i].S;
    }
    ll ans=(1ll*n*n)%mod;
    for(int msk=1;msk<(1<<m);msk++){
	vv2.clear();
	for(int i=0;i<m;i++){
	    if(bit(msk,i))
		vv2.PB(vv[i]);
	}
	vector<int>perm(sz(vv2));
	for(int i=0;i<sz(vv2);i++)
	    perm[i]=i;
	do{
	    vector<pii>vv3(sz(vv2));
	    for(int i=0;i<sz(vv2);i++)
		vv3[i]=vv2[perm[i]];
	    //	    for(pii pp:vv3) cout<<pp.F<<" "<<pp.S<<" || ";
	    //	    cout<<endl;

	    int lst=-1,frst=-1;
	    for(int msk2=0;msk2<(1<<sz(vv2));msk2++){
		st.clear();
		frst=vv3[0].F,lst=vv3[0].S;
		if(bit(msk2,0)) swap(frst,lst);
		st.insert(frst);

		//		cout<<"START    "<<frst<<" "<<lst<<" ";

		for(int i=1;i<sz(vv3);i++){
		    pii p=vv3[i];
		    if(bit(msk2,i)) swap(p.F,p.S);

		    //		    cout<<p.F<<" "<<p.S<<" ";

		    int A=lst,B=p.F,C=lca(A,B);
		    while(A!=C){
			if(st.count(A)) goto Hell;
			st.insert(A);
			A>>=1;
		    }
		    while(B!=C){
			if(st.count(B)) goto Hell;
			st.insert(B);
			B>>=1;
		    }
		    if(st.count(C)) goto Hell;
		    st.insert(C);

		    lst=p.S;
		}
		if(st.count(lst))
		    goto Hell;
		st.insert(lst);
		ans=(ans+solve(frst,lst))%mod;
	    Hell:;
	    }
	    //	    cout<<"SAMEEEEEEEEEEEEE "<<sz(vv2)<<endl;
	}while(next_permutation(perm.begin(),perm.end()));
    }
    return cout<<ans<<endl,0;
}


#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n;
    do {
        cin>>n;
    } while(n<1 || n>90);
    int Max=0; int bien;
    vector<int> a;
    do {
        cin>>bien;
    } while(bien<1 || bien>90);
     a.push_back(bien);
    if(a[0]>15) Max=15;
    for(int i=1; i<n; i++) {
        do {
            cin>>bien;
        } while(bien<1 || bien>90 || bien>a[i-1]);
        a.push_back(bien);
        if(a[i]-a[i-1]>15) {
            Max=a[i-1]+15;
        }
    }
    if(Max) cout<<Max;
    else if(a[a.size()-1]+15>=90) {
        cout<<90;
    }
     else {
        cout<<a[a.size()-1]+15;
     }
}


///A. Cakeminator

#include <iostream>
using namespace std;
int row , colomn ;
int maximum_row , maximum_col;
char board[10][10];
int main()
{
    bool res_row[10] , res_col[10];
    while(1){
    cin >> row >> colomn ;
    for (int i =0 ; i < row ; i ++ )
    {
        for(int j = 0 ; j < colomn ; j ++)
        {
            cin >> board[i][j];
            if(board[i][j] == 'S'){res_row[i] = true;
            res_col[j] = true;}
        }
    }
        for (int i =0 ; i < row ; i ++ )
        {
            if(res_row[i] == false)
            {
                maximum_row ++;
            }
        }
    for (int i =0 ; i < colomn ; i ++ )
        {
            if(res_col[i] == false)
            {
              maximum_col ++;
            }
        }

cout << (maximum_row * colomn + maximum_col * row) -  maximum_col*maximum_row<< endl;
}
    return 0;
}


#include <cassert>
#include <complex>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <numeric>
#include <limits>
#include <sstream>
#include <utility>

#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

//#include "bigint.h"

#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define init(st) memset(st, 0, sizeof(st))
#define ll long long

// String operations
template<class T>
void splitstr(const string &s, vector<T> &out) {
    istringstream in(s);
    out.clear();
    copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}

template<class T>
void initArray(T *arr, int size, T value) {
    for(int i = 0; i < size; i++) {
		arr[i] = value;
    }
}

template<class T>
T readValue(string s) {
	T result;
	istringstream sin(s);
	sin >> result;
	return result;
}

// Arithmetic operations
template<class T>
inline T gcd(T a, T b) {
	return (!a) ? b : gcd(b % a, a);
}

template<class T>
inline T mod(T a, T p) {
	a %= p;
	return (a < 0) ? a + p : a;
}

template<class T>
inline int numbits(T n) {
	return (!n) ? 0 : 1 + numbits(n & (n - 1));
}

template<class T>
inline T inverse(T a, T m) {
	a = mod<T>(a,m);
	return (a==1) ? 1 : mod((1-m*inverse(m%a,a))/a,m);
}

template<class T>
inline bool isPrime(T a) {
	T lim = (T)sqrt((double)a);
	for (T i = 2; i < lim; i++)
		if(a % i == 0)
			return false;
	return true;
}

template<class T>
inline T power(T a, T p, T mod) {
	if(!p) return 1;
	T temp = power(a, p>>1, mod);
	temp = (temp * temp) % mod;
	if (p&1)
		temp = (temp * a) % mod;
	return temp;
}

void get_primes(int start, int end, vector<int> &vi) {
	int *p = new int[end + 1];
	initArray<int>(p, end+1, 0); p[1] = 1;

	for (int i = 2; i <= end; i++) {
		if (!p[i]) {
			if (i >= start)
				vi.push_back(i);

			for (int j = 2*i; j <= end; j += i)
				p[j] = 1;
		}
	}
}

// Graph operations
bool dfs(int current, int final, int total, int* visited, int **edges, bool flow) {
	if (current == final)
		return true;
	if (visited[current])
		return false;
	visited[current] = true;
	for (int i = 0; i < total; i++)
		if (edges[current][i] && dfs(i, final, total, visited, edges, flow)) {
			if (flow) {
				edges[current][i]--;
				edges[i][current]++;
			}
			return true;
		}
	return false;
}

int flow(int in, int out, int total, int **edges) {
	int result = 0;
	int *visited = new int[total];
	while (initArray<int>(visited, total, 0), dfs(in, out, total, visited, edges, true))
		result++;
	return result;
}

// Disjoint datasets
void create_set(int x, int *P, int *rank) {
	P[x] = x;
	rank[x] = 0;
}

int find_set(int x, int *P) {
	if (x != P[x])
		P[x] = find_set(P[x], P);
	return P[x];
}

bool merge_sets(int x, int y, int *P, int *rank) {
	int Px = find_set(x, P);
	int Py = find_set(y, P);
	if(Px == Py)
		return false;
	if (rank[Px] > rank[Py]) P[Py] = Px;
	else P[Px] = Py;
	if (rank[Px] == rank[Py])
		rank[Py]++;
	return true;
}

// Binary tree operations
int read_cum_freq(int index, int *tree) {
	int sum = 0;
	while (index) {
		sum += tree[index];
		index -= (index & -index);
	}
	return sum;
}

void upd_freq(int index, int mxIndex, int value, int *tree) {
	while (index <= mxIndex) {
		tree[index] += value;
		index += (index & -index);
	}
}

int read_freq(int index, int *tree) {
	return read_cum_freq(index, tree) - read_cum_freq(index-1, tree);
}

// String algos.
void build_failure_function(const string &str, int *temp_arr) {
    temp_arr[0] = temp_arr[1] = 0;
    for (int i = 2; i <= static_cast<int>(str.size()); i++) {
        temp_arr[i] = -1;
        for (int ind = temp_arr[i-1]; temp_arr[i] == -1; ind = temp_arr[ind]) {
            if (str[ind] == str[i-1]) {
                temp_arr[i] = ind + 1;
            } else if (ind == 0) {
                temp_arr[i] = 0;
            }
        }
    }
}

void KMP(const string &s1, const string &s2, int *res) {
    int *temp_arr = new int[s2.size() + 1];
    build_failure_function(s2, temp_arr);

    int i = 0;
    int ind = 0;
    while (i < static_cast<int>(s1.size())) {
        if (s1[i] == s2[ind]) {
            res[i] = ++ind;
            if (res[i] == s2.size()) {
                ind = temp_arr[ind - 1];
            }
            i++;
        } else if (ind == 0) {
            res[i++] = 0;
        } else {
            ind = temp_arr[ind];
        }
    }

    delete [] temp_arr;
}

// Setup
void setup(int value) {
	freopen("input.txt", "r", stdin);
    if (value) {
		freopen("output.txt", "w", stdout);
    }
}

bool arr[8][8];

int dx[] = {2, 1, -1, -2, -2, -1, 1, 2};
int dy[] = {1, 2, 2, 1, -1, -2, -2, -1};

void xset(int x, int y) {
    if (x >= 0 && y >= 0 && x < 8 && y < 8)
        arr[x][y] = true;
}

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    init(arr);
    int x, y;
    x = s1[0] - 'a';
    y = s1[1] - '1';
    arr[x][y] = true;
    arr[s2[0]-'a', s2[1]-'1'] = true;
    for (int i = 0; i < 8; i++) {
        arr[x][i] = arr[i][y] = true;
        xset(x + dx[i], y + dy[i]);
        xset(s2[0] - 'a' + dx[i], s2[1] - '1' + dy[i]);
    }
    int res = 0;
    for (int i = 0; i < 8; i++)
        for (int j = 0; j < 8; j++)
            if (!arr[i][j]) res++;
    std::cout << res << std::endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define mod 1000000007
vector<int> parent,len;
int n,m,k;

int binomialCoeff(int n, int k)
{
    int res = 1;

    // Since C(n, k) = C(n, n-k)
    if ( k > n - k )
        k = n - k;

    // Calculate value of
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
    for (int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}

void init(){
    parent.resize(n+1);
    len.resize(n+1);
    for(int i=1;i<=n;i++){
        parent[i] = i;
        len[i] = 1;
    }
}

int find(int n){
    if(parent[n] == n)
        return n;
    return parent[n] = find(parent[n]);
}

void un(int a, int b){
    int x = find(a);
    int y = find(b);

    if(x == y)
        return;
    if(len[x] < len[y])
        swap(x,y);
    parent[y] = x;
    len[x] += len[y];
}

signed main()
{
    cin>>n>>m>>k;
    init();
    for(int i=1;i<=n-k+1;i++){
        int m = i,n=i+k-1;
        while(m<=n){
            un(m,n);
            m++;
            n--;
        }
    }

    int count=0;
    for(int i=1;i<=n;i++){
        if(parent[i] == i){
            count++;
        }
    }

    // cout<<n<<" "<<count<<endl;
    cout<<binomialCoeff(m,count);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//int x;
/*
int recfunc(int curpos, int jumpsofar, int weightage){
    if(curpos == x){
        cout<<jumpsofar;
        return 1;
    }

    return (recfunc(curpos - weightage,jumpsofar+1, weightage+1) ||
            recfunc(curpos + weightage,jumpsofar+1, weightage+1));

}*/

queue<int>a;

int main(){
    long long int x,aa,bb=0,cc;
    cin>>x;
    a.push(0);

  while(!a.empty()){
      aa = a.front();a.pop();
       if(aa == x){
        cout<<bb<<endl;
        break;
     }
     bb++;
     a.push(aa - bb);a.push(aa + bb);

  }
   return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string.h>
#include <stdlib.h>

using namespace std;
// vector push_back push front top empty pop make_pair long long insert begin end
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair <int,int> > vpi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
#define F first
#define ln '\n'
#define S second
#define PB push_back
#define MP make_pair
#define B begin()
#define RB rbegin()
#define E end()
#define RE rend()
#define Z size()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define L length()
#define show(a) cerr << " *** " << a << endl;
#define show1(a) cerr << " /// " << a << endl;
#define valid(a,b,c) (a >= b && a < c ? 1 : 0)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int mod = (int)1e9 + 7;
const ll INF64 = 3e18;
void smxl(ll &a, ll b){if (a < b)a=b;}
void smnl(ll &a, ll b){if (a > b)a=b;}
void adsl(ll &a, ll b){a += b;if (a >= mod)a -= mod;}
void misl(ll &a, ll b){a -= b;if (a >= mod)a -= mod; if (a < 0)a += mod;}
void smx(ll &a, ll b){if (a < b)a=b;}
void smn(ll &a, ll b){if (a > b)a=b;}
void ads(ll &a, ll b){a += b;if (a >= mod)a -= mod;}
void mis(ll &a, ll b){a -= b;if (a >= mod)a -= mod; if (a < 0)a += mod;}
ll gcd(ll a, ll b) {return (b==0? a:gcd(b,a%b));}
ll egcd(ll a, ll b, ll & x, ll & y) {if (a == 0){x = 0;y = 1;return b;}ll x1, y1;ll d = egcd(b % a, a, x1, y1);x = y1 - (b / a) * x1;y = x1;return d;}
ll mbinp(ll a, ll b){a %= mod;if (b == 0)return 1;ll ans = mbinp(a, b/2);ll tmp = (ans * ans) % mod;if (b % 2)return ((tmp * a) % mod);return ((tmp) % mod);}
ll binp(ll a, ll b){if (b == 0)return 1;ll ans = binp(a, b/2);ll tmp = (ans * ans);if (b % 2)return ((tmp * a));return ((tmp));}
long long C(int n, int m){ll ret=1;for(int i=1;i<=m;i++){ret*=(n-i+1);ret/=i;}return ret;}
long long overbinp(long long a, int b){long long res = 1;while (b){if (b & 1){if (res < INF64 / a) res *= a;else return INF64;}if (b > 1){if (a < INF64 / a) a *= a;else return INF64;}b >>= 1;}return res;}
/*const int FMAXN = 1000 * 1000 + 10;int fen[FMAXN];void add(int x, int val){for (int i = x + 1; i < MAXN; i += i & (-i)) fen[i] += val;}int get(int x){int ans = 0;for (int i = x; i > 0; i -= i & (-i)) ans += fen[i];return ans;}int sum(int x, int y){return get(y) - get(x);}*/
/*int distfloor(int n){int sum;int la;for (int i = 1; i <= n; i = la+1){la = n/(n/i);sum++;show(n/i);}return sum;}*/
//int pointsCoveredBySegment(pi a, pi b){return(gcd((int)abs(a.F-b.F),(int)abs(a.S-b.S))+1);}
//segment inters
/*struct seg{int x1, y1, x2, y2;seg(){};};
struct line{long long Al, Bl, Cl;line(){};line(seg a){Al = a.y1 - a.y2;Bl = a.x2 - a.x1;Cl = -Al * a.x1 - Bl * a.y1;};};
int get(seg a){int dx = a.x1 - a.x2;int dy = a.y1 - a.y2;return __gcd(abs(dx), abs(dy)) + 1;}
long long det(long long a, long long b, long long c, long long d){return a * d - b * c;}
bool in(int x, int l, int r){if (l > r) swap(l, r);return (l <= x && x <= r);}
bool inter(seg a, seg b, int& x, int& y){line l1(a), l2(b);long long dx = det(l1.Cl, l1.Bl, l2.Cl, l2.Bl);long long dy = det(l1.Al, l1.Cl, l2.Al, l2.Cl);long long d = det(l1.Al, l1.Bl, l2.Al, l2.Bl);if (d == 0)return false;if (dx % d != 0 || dy % d != 0)return false;x = -dx / d;y = -dy / d;if (!in(x, a.x1, a.x2) || !in(y, a.y1, a.y2))return false;if (!in(x, b.x1, b.x2) || !in(y, b.y1, b.y2))return false;return true;}*/
/*st int nax = 105;
int par[nax];
int siize[nax];
int get(int x)
{
  return (x == par[x] ? x : par[x] = get(par[x]));
}
void merge(int a, int b) {
  int x = get(a);
  int y = get(b);
  if (x == y)return;
  if (siize[x] < siize[y])swap(x,y);par[y] = x;siize[x] += siize[y];}*/
//const int nx = 1e5+10;ll cmd[nx];ll civ[nx];void initcmod(){	cmd[0] = 1;	cmd[1] = 1;	REP(i,2,nx)	{		cmd[i] = cmd[i-1]*i;		cmd[i] %= mod;	}	REP(i,0,nx)		civ[i] = mbinp(cmd[i],mod-2);}ll cmod(int n, int m){	initcmod();	ll ans = cmd[n];	ans *= civ[m];	ans %= mod;	ans *= civ[n-m];	ans %= mod;	return ans;}
//double triarea(double a, double b, double c){double p= (a+b+c)/2;return (sqrt(p*(p-a)*(p-b)*(p-c)));}
//ll diag(ll n){return ((n*(n-1))/2 - n);}
//number of divs of n=p^a*q^b*r^c  == (a+1)*(b+1)*(c+1)
//sum of divs of n=p^a*q^b*r^c  == (p^(a+1)-1)/(p-1) * (q^(b+1)-1)/(q-1) * (r^(c+1)-1)/(r-1)
//prod of divs of n=p^a*q^b*r^c  == n ^ (((a+1)*(b+1)*(c+1))/2)
void display(vi &a){for(int z : a)cout << z << " ";cout << endl;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
  int n;
  cin >> n;
  queue<pi>kyou;
  kyou.push(MP(n,2));
  int ans = 1e9;
  while(kyou.Z)
  {
    pi x = kyou.front();
    kyou.pop();
    if (x.S==0)
    {
      ans = min(ans,x.F);
      continue;
    }
    vi divs;
    int tmp = x.F;
    for(int i = 2; i*i <= tmp;i++)
    {
      if(tmp%i == 0)
        divs.PB(i);
      while(tmp%i==0)
        tmp/=i;
    }
    if (tmp!= 1)
      divs.PB(tmp);
    kyou.push(MP(x.F,x.S-1));
    for (int z : divs)
    {
      int tmp = x.F-1;
      while(tmp%z != 0 && tmp > z)
      {
        kyou.push(MP(tmp,x.S-1));
        tmp--;
      }
    }
  }
  cout << ans;
}


#include<iostream>

using namespace std;

int main()
{
int n,a[50]={-1};
cin>>n;
long int prod=1;
int m,j,l=0;
while(n>=0)
{
m=n%10;
a[l]=m;
l++;
n/=10;
}
for( j=0;j<=l;j++)
{
	if(a[j]==9 || a[j]==6 || a[j]==5 || a[j]==4 || a[j]==2)
		prod=prod*1;
	else if(a[j]==8 || a[j]==0)
		prod=prod*2;
	else if(a[j]==7 || a[j]==1)
		prod=prod*5;
 	else
		prod=prod*3;
}
cout<<prod<<endl;
return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long llong;

const llong MOD = 1e9 + 7;

inline tuple<llong, llong, llong> count_remainders(int l, int r) {
	return make_tuple(r / 3 - l / 3, (r + 2) / 3 - (l + 2) / 3, (r + 1) / 3 - (l + 1) / 3);
}

void solve(int n, int l, int r) {
	vector<vector<llong>> dp(3, vector<llong>(n + 1, 0));
	dp[0][0] = 1;

	tuple<llong, llong, llong> abc = count_remainders(l, r);

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				dp[(j + k) % 3][i + 1] += dp[j][i] * abc.get(k);
				dp[(j + k) % 3][i + 1] %= MOD;
			}
		}
	}

	cout << dp[0][n] << "\n";
}

int main() {
	int n, l, r; cin >> n >> l >> r;

	solve(n, l, r);

	return 0;
}


#include <iostream>
using namespace std;
char table[9][9];
bool lineGoodW[9] = {1,1,1,1,1,1,1,1,1};
bool lineGoodB[9] = {1,1,1,1,1,1,1,1,1};
int main() {
    for(int i = 0 ; i < 8 ; i++){
            cin>>table[i];
    }
    char *p;
    char *t;
    int P,T;
    int firstW = 0,firstB = 0;
    for(int i = 0 ; i < 8 ; i++){
        for(int j = 0 ; j < 8 ; j++){
            if(table[i][j] == 'B')
                lineGoodW[j] = false;
            else if(table[i][j] == 'W' && lineGoodW[j] == true){
                firstW = i;
                i = -1;
            }
        }
    }
    for(int i = 7 ; i >= 0 ; i--){
        for(int j = 0 ; j < 8 ; j++){
            if(table[i][j] == 'W')
                lineGoodB[j] = false;
            else if(table[i][j] == 'B' && lineGoodB[j] == true){
                firstB = 7-i;
                i = -1;

            }
        }
    }
    cout << firstB << firstW;
    if(firstB < firstW)
        cout << "B";
    else
        cout << "A";

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int r1,r2,c1,c2,d1,d2;
    while(cin>>r1>>r2>>c1>>c2>>d1>>d2)
    {
        int b=(r1-c1+d2)/2;
        int a=r1-b,c=d2-b,d=c2-b;
        int flag=1;
        if(a+b!=r1||c+d!=r2||a+c!=c1||b+d!=c2||a+d!=d1||b+c!=d2)flag=0;
        if(flag)
        {cout<<r1-b<<' '<<b<<endl;
        cout<<d2-b<<' '<<c2-b<<endl;
        }
        else cout<<-1<<endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <stack>
#include <utility>

using namespace std;
int n,m;

int main() {
	scanf("%d%d", &n,&m);
	vector<vector<bool>> vis(n, vector<bool>(m,false));
	string hh; cin >> hh;
	string vv; cin >> vv;
	stack<pair<int,int>> st;
	st.push(make_pair(0, 0));
	int r = 1;
	vis[0][0] = true;
	while (!st.empty()) {
		auto &c = st.top(); st.pop();
		int x = c.first;
		int y = c.second;
		if (hh[x] == '>'&& (y+1) < m && !vis[x][y+1]) {
			st.push(make_pair(x, y+1));
			r++;
		}else if (hh[x] == '<'&&y - 1>=0 && !vis[x][y-1]) {
			st.push(make_pair(x , y-1));
			r++;
		}
		if (vv[y] == 'v' && (x + 1) < n && !vis[x+1][y]) {
			st.push(make_pair(x+1, y)); r++;
		}
		else if (vv[y] == '^'&&x - 1 >= 0 && !vis[x-1][y]) {
			st.push(make_pair(x-1, y)); r++;
		}
	}
	if (r == m * n) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}

}