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

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

b = A("b")
k = B("k")
c = A("c")
m = A("m")
i = A("i")
f = A("f")
h = B("h")

b.y = k
k.u = h
c.y = k
m.y = h
i.y = k
f.y = h
h.u = k
assert i.y.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

b = A("b")
k = B("k")
c = A("c")
m = A("m")
i = A("i")
f = A("f")
h = B("h")

b.y = k
k.u = h
c.y = k
m.y = h
i.y = k
f.y = h
h.u = k
assert i.y.u.u.u.u.u.txt == "h"