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

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

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

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

h.u = j
h.x = f
i.z = j
a.w = f
a.z = g
f.w = a
f.z = h
l.w = f
l.z = g
g.u = j
g.x = a
j.z = i
assert j.z.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: C = None
        self.txt = txt

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

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

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

h.u = j
h.x = f
i.z = j
a.w = f
a.z = g
f.w = a
f.z = h
l.w = f
l.z = g
g.u = j
g.x = a
j.z = i
assert j.z.z.z.z.z.z.z.txt == "i"