2202 问题 B: I can do it!(I)

时间限制: 2s 内存限制: 512MB 提交: 31 解决: 1
题目描述

You have a recursive formula such as

I can do it!(I)

It is easy to calculate if n is smaller than 1000. But when n comes to 109, it may be hard to calculate the answer unless you can really computing!

I think you have this ability, so just do it!

But the answer may be to large to calculate, so you can only calculate the answer mod 1e9+7.
输入

The input consists of many test cases, but no more than 5 cases.

Each case will have three lines.

There are two integers n, k in the first line. k<n≤1010, 1≤k≤100

The second line has k numbers, and the i-th number is ai. |ai|≤109

The third line has k numbers too, and the i-th number is Fi|Fi|≤109

输出

For each test case, you should output a number describe the answer.

样例输入
83167 5
270044411 64763 389502790 165642235 3775223
136407894 699370879 998658047 184722627 -678977043
79679 3
427397619 485492671 476934139
-360282785 178718524 606397373
样例输出
299168603
559548063
提示
零基础同学可以先学习视频课程,包含C/C++、Python、百练、蓝桥杯辅导、算法数据结构等课程,提供视频讲解以及配套习题,还有老师答疑,点击这里了解课程详情

比赛公告

题号:2201,2202,2203,2204,2205,2206,2207,2208,2209,2210

点击上方导航栏的训练,点击题库,寻找题号即可找到对应题目,比赛结束后,请通过训练->题库->寻找对应题目的方式做题

因为不确定因素太多,就不再安排大家轮流讲题了,大家做不出题可以在测试结束后去题库找对应的题目看题解,希望大家自觉练习,认真练习,考核测试会采取不同与现在测试的方式,两个月后综合测试成绩不达标者会退出实验室,希望大家认真对待