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

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

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

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

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

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

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

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

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