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

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

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

class D:
    def __init__(self, txt: str):
        self.y: D = None
        self.t: B = None
        self.txt = txt

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

m.q = a
m.z = g
g.u = e
g.p = e
g.v = m
g.q = l
l.s = c
l.r = m
l.p = g
e.y = c
e.t = g
n.s = h
n.r = a
n.p = g
c.y = h
c.t = g
a.q = m
a.z = g
h.y = e
h.t = g
assert l.r.z.q.s.t.q.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.z: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: D = None
        self.t: B = None
        self.txt = txt

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

m.q = a
m.z = g
g.u = e
g.p = e
g.v = m
g.q = l
l.s = c
l.r = m
l.p = g
e.y = c
e.t = g
n.s = h
n.r = a
n.p = g
c.y = h
c.t = g
a.q = m
a.z = g
h.y = e
h.t = g
assert l.r.z.q.s.t.q.r.z.txt == "g"