Generate Menu Access Keys This is thematically similar to Generate keyboard shortcuts for a menu, but its actually a pretty different challenge.

Let's take PHPStorm's menu as an example:

New Project
New
Open Directory
Open
Open URL
New Project from Existing Files
Save As
Open Recent
Close Project
Rename Project


We need to assign a single-letter access keys for each of these menu items.  Typically we pick the first letter, but if you notice, many of the above menu items start with the same letter!

Therefore, we'd want to pick:

P -&gt; New Project
N -&gt; New
D -&gt; Open Directory
O -&gt; Open
U -&gt; Open URL
F -&gt; New Project from Existing Files
S -&gt; Save As
E -&gt; Open Recent  (We don't pick "R" here because "Rename Project" needs it)
C -&gt; Close Project
R -&gt; Rename Project


Therefore, for our list we need to maximize (in order of importance):


The number of access keys actually contained in the string.


["X" -&gt; "New"] should be avoided unless its your only option.

The number of access keys that start a word. 


["N"-&gt;"New", "P"-&gt;"New Project"] is better than ["E"-&gt;"New", "N"-&gt;"New Project"]

The number of access keys that start the sentence.


["N"-&gt;"New Project"] is better than ["P"-&gt;"New Project"]



Access keys are case-insensitive, so if your menu is ["Add", "add"], one of them will need to use D as its access key.

Input/output

You need to input a list of strings.  The strings will only contain alphabetic characters and spaces.  You can optionally input a single string with a delimiter for each of the lines.  You can assume there will be between 1 and 26 menu items (inclusive).

You need to output either:


A Key-value map, where the key is the access key letter, and the value is the string it maps to
A list of access key letters, where the Nth entry pairs with the Nth item in the list.


You can either return the objects themselves, or a reasonable string representation of them. Access key letters can be in any case.

Test Cases:

A                            -&gt; A
Add,add                      -&gt; A,D
Add To,Add                   -&gt; T,A
Add To,Add Around,Add For    -&gt; T,A,F
Add To,Flip To,Add For       -&gt; T,F,A
Add,add,Dip,Around           -&gt; A,D,I,R
Add,add,Dad                  -&gt; A,B,D      
Add,add,Dad,dad,ad dadad,B   -&gt; A,C,D,E,Z,B
A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,A,B,C -&gt; A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z
A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,Add,Bz,Cx -&gt; A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,Y,Z,X
Jelly, 41 bytes
e/€S;eḲ1ịⱮƊ}¥/€;=Ḣ¥/€µS
LØAœ!ż€³Œu¤ÇÐṀẎḢ€

Try it online!
This is really messy and also O(26^n) lol.
Explanation: literally just brute forces it ._.
-6 bytes thanks to caird coinheringaahing