Clustering appearance and shape by learning jigsaws