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

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

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

d = A("d")
l = B("l")
g = C("g")
h = A("h")
j = B("j")
e = A("e")
n = A("n")
m = B("m")
k = B("k")
a = A("a")

d.q = k
d.w = a
l.q = g
l.p = g
l.z = d
g.p = h
g.r = h
h.q = k
h.w = e
j.q = g
j.p = g
j.z = h
e.q = m
e.w = d
n.q = m
n.w = e
m.q = g
m.p = g
m.z = e
k.q = g
k.p = g
k.z = h
a.q = l
a.w = n
assert g.r.q.z.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: A = None
        self.txt = txt

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

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

d = A("d")
l = B("l")
g = C("g")
h = A("h")
j = B("j")
e = A("e")
n = A("n")
m = B("m")
k = B("k")
a = A("a")

d.q = k
d.w = a
l.q = g
l.p = g
l.z = d
g.p = h
g.r = h
h.q = k
h.w = e
j.q = g
j.p = g
j.z = h
e.q = m
e.w = d
n.q = m
n.w = e
m.q = g
m.p = g
m.z = e
k.q = g
k.p = g
k.z = h
a.q = l
a.w = n
assert g.r.q.z.w.w.txt == "d"