Buddhist monasteries were both important to the japanese imperial state and a source of tension with the local populace, largely due to what exemption granted to them?