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

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

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

j = A("j")
d = B("d")
n = C("n")
c = A("c")
a = C("a")
m = B("m")

j.q = m
j.t = n
j.w = a
d.t = c
d.z = j
d.q = n
n.s = d
c.q = d
c.t = a
c.w = a
a.s = m
m.t = c
m.z = c
m.q = n
assert n.s.z.t.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.t: C = None
        self.w: C = None
        self.txt = txt

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

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

j = A("j")
d = B("d")
n = C("n")
c = A("c")
a = C("a")
m = B("m")

j.q = m
j.t = n
j.w = a
d.t = c
d.z = j
d.q = n
n.s = d
c.q = d
c.t = a
c.w = a
a.s = m
m.t = c
m.z = c
m.q = n
assert n.s.z.t.s.t.txt == "c"