NIO owns an awesome API platform with various functionalities such as "Graph APIs", "Email APIs'' and "Vision APIs''. Today, there are lots of third party applications using NIO's APIs, to better manage the access permission of each API, NIO is developing his own OAuth2 service.
There are

functionalities of the API platform labeled with

. In order to call the APIs of the

-th functionality, an OAuth token with the

-th capability is needed.
NIO creates various templates for third party applications to use when doing authorization. If an application uses the

-th template to do authorization, a token with capabilities

is granted, using which, the application is able to call functionality

.
Each third party application has its API requirements

, which means it needs to call APIs of

functionalities. To achieve this, the application must do several authorizations using the pre-defined templates to get tokens with enough capabilities.
After defining

templates, NIO wants to know how the user experience of his templates is. Hence, he defines the degree of an application as the minimal authorizations it has to make to meet all its API requirements. If an application's API requirements cannot be satisfied even after using all the templates, just ignore it because NIO doesn't care.
As the intern of NIO, NIO wants you to tell him the number of applications with degree

among all possible

applications. Two applications are consider different iff some of their API requirements are different.