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

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

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

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

i.z = k
i.r = e
e.x = h
e.y = i
e.z = k
b.u = e
b.r = e
h.u = e
h.r = e
k.u = e
k.r = e
j.u = e
j.r = e
assert k.r.y.r.x.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.r: B = None
        self.txt = txt

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

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

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

i.z = k
i.r = e
e.x = h
e.y = i
e.z = k
b.u = e
b.r = e
h.u = e
h.r = e
k.u = e
k.r = e
j.u = e
j.r = e
assert k.r.y.r.x.u.z.txt == "k"