class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

l = A("l")
g = B("g")
b = B("b")
n = B("n")
h = B("h")
k = A("k")

l.u = n
g.s = k
b.s = l
n.s = k
h.s = l
k.u = h
assert k.u.s.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

l = A("l")
g = B("g")
b = B("b")
n = B("n")
h = B("h")
k = A("k")

l.u = n
g.s = k
b.s = l
n.s = k
h.s = l
k.u = h
assert k.u.s.u.s.txt == "k"