Two-way Node Popularity Model for Directed and Bipartite Networks