#include #pragma GCC optimize("Ofast") using namespace std; using std::cout; using std::cin; using std::endl; using ll=long long; using ld=long double; ll ILL=2167167167167167167; const int INF=2100000000; const ll mod=1e9+7; #define rep(i,a) for (int i=0;i using _pq = priority_queue, greater>; template ll LB(vector &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();} template ll UB(vector &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();} template bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;} template bool chmax(T &a,const T &b){if(a void So(vector &v) {sort(v.begin(),v.end());} template void Sore(vector &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});} void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";} template void vec_out(vector &p){for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout< T min(vector &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;} template T max(vector &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;} //https://ei1333.github.io/library/other/xor-shift.cpp.html struct XorShift { private: constexpr static double R = 1.0 / 0xffffffff; uint64_t x; public: explicit XorShift(uint64_t seed = 88172645463325252ull) : x(seed) {} template< typename T = uint64_t > inline T get() { // [0, 2^64) x ^= x << 7ull; x ^= x >> 9ull; return x; } inline uint32_t get(uint32_t r) { // [0, r) return ((uint64_t) get< uint32_t >() * r) >> 32ull; } inline uint32_t get(uint32_t l, uint32_t r) { // [l, r) return l + get(r - l); } inline double probability() { // [0.0, 1.0] return get< uint32_t >() * R; } }; template void shuffle_vector(vector &p,XorShift &table){ int L=p.size(); for(int i=0;i>t; rep(i,t) solve(); } void solve(){ int N,K; cin>>N>>K; XorShift table(167); vector p={2,3,4,5,6,7,8}; int M=p.size(); ld ans=0; vector val(N); vector T(K),U(K); rep(i,K) cin>>T[i]; rep(i,K) cin>>U[i]; auto f=[](int a,int time)->int{ time%=(a*4); if(time<=a) return time; if(time+a>=a*4) return time-a*4; return a*2-time; }; while(clock()<1.9*CLOCKS_PER_SEC){ vector q(M+1); q[M]=N; rep(i,M-1) q[i]=table.get(N+1); So(q); vector tmp; rep(i,M){ rep(j,q[i+1]-q[i]) tmp.push_back(p[i]); } ld tmp1=0,tmp2=0; rep(k,K){ rep(i,M) rep(j,i){ tmp1+=(ld)((q[j+1]-q[j])*(q[i+1]-q[i]))*(ld)(abs(f(p[i],T[k])-f(p[j],T[k])))/(ld)(p[i]+p[j]); } } rep(k,K){ int A=INF,B=-INF; rep(i,N){ int C=f(tmp[i],U[k]); chmin(A,C); chmax(B,C); } tmp2+=1/sqrtl(1+(ld)(B-A)/(ld)(20)); } tmp1*=tmp2; if(chmax(ans,tmp1))val=tmp; } rep(i,N){ cout<