A code golf challenge, m'kay Mr. Mackey is a South Park character well-known for adding "m'kay" in everything he says.

Write a program or function that transforms a string of text into something Mr. Mackey would say.

M'kay placement


m'kay has a random 50% chance of being added after the punctuations ,, ., ? and !. If that is the case, it will be followed by the exact same punctuation mark that preceeds it and preceeded by a space.

For example, in the sentence Test, test., there are two places where m'kay can be added: after the comma, and after the period, with a 50% chance at each place. Possible results would be Test, m'kay, test. or Test, test. M'kay. or Test, m'kay, test. M'kay..
There must always be at least one m'kay added. Moreover, it cannot always be at the same place and each valid place where m'kay could be added must occur with equal probability. That is, you can't add m'kay always at the end of the string if because of randomness you never added any m'kay. If there is only one m'kay, it must have the same probability of appearing in each valid position, even though its presence is enforced.
If m'kay is after ?, . or !, the m must be uppercased.
The number of m in m'kay must be uniformely picked between 1 and 3. That is, m'kay, mm'kay and mmm'kay are all possible choices, each with probability 0.33... If it must be uppercased (see above rule), all m must be uppercased.


Inputs, outputs


Inputs are ASCII strings containing characters from ASCII Dec 32 (Space) to ASCII Dec 126 (Tilde ~). There are no linebreaks in the input. You may assumed that any input will contain at least one of , . ? !.
You may assume that there are no m'kay or any of its variants in the input.

Inputs may be taken from STDIN, function arguments, command line, or anything similar.
Output may be via STDOUT, a function return, or something similar.


Test cases


Input: Test.


Possible output: Test. M'kay.


Input: Programming Puzzles &amp; Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.


Possible output: Programming Puzzles &amp; Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. MMM'kay. It's 100% free, mm'kay, no registration required.


Input: Drugs are bad, so, if you do drugs, you're bad, because drugs are bad. They can hurt your body, cause drugs are bad.


Possible output: Drugs are bad, m'kay, so, if you do drugs, you're bad, m'kay, because drugs are bad. They can hurt your body, m'kay, cause drugs are bad. M'kay.


Input: Do you understand? Really? Good!


Possible output: Do you understand? MM'kay? Really? Good! MMM'kay!

Scoring

This is code-golf, so the shortest code in bytes wins, m'kay?
APL (66)

{∊⍉⍵⍪⍉⍪(¯1+⌈?2×⍵∊',.!?')/¨{' ',⍵,⍨'''kay',⍨'mM'[1+⍵≠',']/⍨?3}¨⍵}⍣≢


Result of 10 runs:

      ↑ ({∊⍉⍵⍪⍉⍪(¯1+⌈?2×⍵∊',.!?')/¨{' ',⍵,⍨'''kay',⍨'mM'[1+⍵≠',']/⍨?3}¨⍵}⍣≢)¨ 10/⊂'Test, test. Test! Test?'
Test, m'kay, test. Test! Test?                  
Test, test. M'kay. Test! MMM'kay! Test? M'kay?  
Test, mm'kay, test. Test! MM'kay! Test? MM'kay? 
Test, mmm'kay, test. Test! Test? M'kay?         
Test, mm'kay, test. Test! Test? M'kay?          
Test, test. MM'kay. Test! Test? MMM'kay?        
Test, test. MMM'kay. Test! MMM'kay! Test? M'kay?
Test, test. Test! MM'kay! Test?                 
Test, mm'kay, test. M'kay. Test! Test?          
Test, test. MM'kay. Test! MM'kay! Test?   


Explanation:


{...}⍣≢: apply the function to the input until the value changes


Generate a M'kay for each character:
{...}¨⍵: for each character in the input:


'mM'[1+⍵≠',']/⍨?3: generate 1 to 3 ms or Ms depending on whether the character was a comma or not.
'''kay',⍨: append the string 'kay. 
⍵,⍨: append the character
' ',: prepend a space.

(¯1+⌈?2×⍵∊',.!?')/¨: for each M'kay', if its corresponding character is one of .,!?, select it with 50% chance, otherwise select it with 0% chance.
⍉⍵⍪⍉⍪: match each selection with its character,
∊: list all the simple elements (characters) in order.