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

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

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

i = A("i")
e = B("e")
n = C("n")
l = B("l")
f = A("f")
d = B("d")
a = B("a")
g = A("g")

i.q = l
i.u = a
i.w = n
e.z = n
n.w = i
n.p = i
l.z = n
f.q = l
f.u = e
f.w = n
d.z = n
a.z = n
g.q = d
g.u = a
g.w = n
assert g.q.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: B = None
        self.w: C = None
        self.txt = txt

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

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

i = A("i")
e = B("e")
n = C("n")
l = B("l")
f = A("f")
d = B("d")
a = B("a")
g = A("g")

i.q = l
i.u = a
i.w = n
e.z = n
n.w = i
n.p = i
l.z = n
f.q = l
f.u = e
f.w = n
d.z = n
a.z = n
g.q = d
g.u = a
g.w = n
assert g.q.z.w.txt == "i"