def can_connect(lhs, rhs):
    """Return True if the lhs string (say, "2b") can connect to the rhs (say, "b2")."""
    if lhs.endswith('2b') and rhs.startswith('b2'): return True
    if lhs.endswith('2s') and rhs.startswith('s2'): return True
    return False