Since I am a Swabbie I'll go with the "official" US Navy Nautical Trivia definition:
Naval Traditions, Customs, & Etiquette
[url]http://www.cpf.navy.mil/cpffacts/customs.htm[/url]
Mind Your P's & Q's
There are few of us who at one time or another have not been admonished to "mind our P's and Q's," or in other words, to behave our best. Oddly enough, "mind your P's and Q's" had nautical beginnings as a method of keeping books on the waterfront.
In the days of sail when Sailors were paid a pittance, seamen drank their ale in taverns whose keepers were willing to extend credit until payday. Since many salts were illiterate, keepers kept a talley of pints and quarts consumed by each Sailor on a chalkboard behind the bar. Next to each person's name, a mark was made under "P" for pint or "Q" for quart whenever a seaman ordered another draught.
On payday, each seaman was liable for each mark next to his name, so he was forced to "mind his P's and Q's" or he would get into financial trouble. To ensure an accurate count by unscrupulous keepers, Sailors had to keep their wits and remain somewhat sober. Sobriety usually ensured good behavior, hence the meaning of "mind your P's and Q's."
And on a related subject:
"To Be Three Sheets in the Wind"
In the days of sailing ships, this is a phrase which refers to the lines used to control the sails of sailing vessels. When these sheets are cast to the wind (let go), it would cause the old sailing ships to shudder and stagger. The resulting track would be the same as that of a drunken Sailor, out of control, and hence "three sheets in the wind."