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

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

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

d = A("d")
a = B("a")
h = C("h")
i = B("i")
l = C("l")
m = A("m")
n = B("n")
c = B("c")
g = B("g")
e = C("e")

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

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

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

d = A("d")
a = B("a")
h = C("h")
i = B("i")
l = C("l")
m = A("m")
n = B("n")
c = B("c")
g = B("g")
e = C("e")

d.q = n
d.u = h
d.z = l
a.s = i
h.w = a
h.r = d
i.s = c
l.w = i
l.r = d
m.q = a
m.u = e
m.z = l
n.s = g
c.s = n
g.s = a
e.w = g
e.r = m
assert m.u.w.s.s.s.s.s.txt == "g"