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

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

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

g = A("g")
j = B("j")
c = C("c")
d = A("d")
e = C("e")
b = B("b")

g.q = j
g.p = c
j.s = c
j.z = b
j.x = e
c.w = e
c.t = e
c.q = d
d.q = j
d.p = c
e.w = c
e.t = c
e.q = g
b.s = c
b.z = j
b.x = e
assert e.q.p.q.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: C = None
        self.txt = txt

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

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

g = A("g")
j = B("j")
c = C("c")
d = A("d")
e = C("e")
b = B("b")

g.q = j
g.p = c
j.s = c
j.z = b
j.x = e
c.w = e
c.t = e
c.q = d
d.q = j
d.p = c
e.w = c
e.t = c
e.q = g
b.s = c
b.z = j
b.x = e
assert e.q.p.q.p.w.txt == "e"