Ab initio three-body interactions for water. I. Potential and structure of water trimer