#include using namespace std; #if __has_include("all.hpp") #include "all.hpp" #else #include #endif using namespace atcoder; using mint = modint; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,mod,q; cin>>n>>mod>>q; mint::set_mod(mod); vectora(n,0); while(q--){ int l,m,r,c,d; cin>>l>>m>>r>>c>>d; for(int i=l-1;i