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

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

a = A("a")
i = B("i")
l = B("l")
k = A("k")
f = A("f")
h = A("h")
g = A("g")

a.y = h
i.u = l
l.u = i
k.y = f
f.y = h
h.y = k
g.y = f
assert g.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

a = A("a")
i = B("i")
l = B("l")
k = A("k")
f = A("f")
h = A("h")
g = A("g")

a.y = h
i.u = l
l.u = i
k.y = f
f.y = h
h.y = k
g.y = f
assert g.y.y.y.y.y.y.y.txt == "f"