We introduce a new one-matrix model with arbitrary potential and matrix-valued background field. Its partition function is a tau-function of KP hierarchy, subjected to a kind of L-1 constraint. Moreover, the partition function behaves smoothly in the limit of infinitely large matrices. If the potential is equal to X(K+1), this partition function becomes a tau-function of K-reduced KP hierarchy, obeying a set of W(K) algebra constraints identical to those conjectured for the double-scaling continuum limit of the (K - 1) matrix model. In the case of K = 2 the statement reduces to an earlier established relation between the Kontsevich model and ordinary 2d quantum gravity. The Kontsevich model with generic potential may be considered as an interpolation between all the models of 2d quantum gravity, with c < 1 preserving the property of integrability and the analogue of the string equation.