void multiply(vector<int> &res, int x) {
long long product, carry = 0;
for(int i = 0; i < res.size(); i++) {
product = res[i] * x + carry;
res[i] = product % 10;
carry = product / 10;
}
while(carry) {
res.push_back(carry % 10);
carry /= 10;
}
}
vector<int> factorial(int N){
vector<int> res = {1};
for(int i = 1; i <= N; i++)
multiply(res, i);
reverse(res.begin(), res.end());
return res;
}