<think>
Okay, I need to implement the tag_trim function. The problem says that a tag might have leading hash and trailing colon markers, and I need to strip those if they're present. The function should return what's left after stripping the markers. Also, it mentions that only one marker of each kind is ever stripped. 

First, I need to understand what exactly is considered a marker. The problem says the tag is wrapped in markers: a leading hash and a trailing colon. So, the structure would be something like #tag: or maybe #tag: but maybe the markers are just the # and :. Wait, the problem says "a leading hash and a trailing colon". So the tag is wrapped in a leading # and a trailing :. So the original tag might look like #example: or maybe #example: but the function is supposed to strip whichever markers are present.

Wait, the function is supposed to strip the markers. So if the tag starts with a #, we should remove that. If it ends with a :, we should remove that. But the problem says "only one marker of each kind is ever stripped". So if the tag has both, we remove both. But if it has only one, we remove that one. 

So the function should check if the tag starts with a # and remove it if present. Then check if the tag ends with a : and remove it if present. But wait, maybe the markers are part of the tag. For example, if the tag is "#example:", then stripping the leading # and trailing : would leave "example". But if the tag is "#example", then only the leading # is stripped, leaving "example". If the tag is "example:", then only the trailing : is stripped, leaving "example". And if the tag is "example", then nothing is stripped.

So the function should first check if the first character is a #. If so, remove it. Then check if the last character is a :. If so, remove it. But wait, after removing the leading #, the string might now end with a :. For example, if the original tag is "#example:", after stripping the #, it becomes "example:", which ends with a :. So we need to check again after the first step.

Wait, but the problem says "only one marker of each kind is ever stripped". So if the tag has both, we remove both. So the steps would be: check if the first character is #, remove it. Then check if the last character is :, remove it. But if the tag is like "##example:", then the first # is stripped, leaving "#example:", then the last : is stripped, leaving "#example". But according to the problem, only one of each is stripped. So maybe the function is supposed to remove the leading # if present, and the trailing : if present, regardless of other markers.

So the function should do the following:

- Check if the first character is a '#'. If yes, remove it.
- Check if the last character is a ':'. If yes, remove it.
- Return the resulting string.

But wait, what if the tag is empty? Well, the problem says that a tag may have markers, but the function is supposed to handle any input. But the problem says that a tag carrying neither marker comes back unchanged. So for example, if the tag is "example", then it's unchanged.

So the steps are:

Take the input string. If it starts with '#', remove the first character. Then, if the resulting string ends with ':', remove the last character. So the order is important. For example, if the tag is "#example:", after removing the leading #, it becomes "example:", which ends with