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

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

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

b = A("b")
h = B("h")
j = C("j")
k = A("k")
e = C("e")

b.u = k
h.t = k
j.r = h
k.u = b
e.r = h
assert b.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

b = A("b")
h = B("h")
j = C("j")
k = A("k")
e = C("e")

b.u = k
h.t = k
j.r = h
k.u = b
e.r = h
assert b.u.u.u.u.u.txt == "k"