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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.u: D = None
        self.t: D = None
        self.p: C = None
        self.txt = txt

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

b = A("b")
h = B("h")
d = C("d")
c = D("c")
f = C("f")
e = C("e")
n = A("n")
m = C("m")
g = C("g")

b.u = m
b.s = c
h.v = b
h.r = b
h.p = c
d.z = c
d.u = c
d.t = c
d.p = m
c.x = n
c.z = h
c.q = e
f.z = c
f.u = c
f.t = c
f.p = e
e.z = c
e.u = c
e.t = c
e.p = m
n.u = f
n.s = c
m.z = c
m.u = c
m.t = c
m.p = g
g.z = c
g.u = c
g.t = c
g.p = f
assert m.p.p.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.s: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.u: D = None
        self.t: D = None
        self.p: C = None
        self.txt = txt

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

b = A("b")
h = B("h")
d = C("d")
c = D("c")
f = C("f")
e = C("e")
n = A("n")
m = C("m")
g = C("g")

b.u = m
b.s = c
h.v = b
h.r = b
h.p = c
d.z = c
d.u = c
d.t = c
d.p = m
c.x = n
c.z = h
c.q = e
f.z = c
f.u = c
f.t = c
f.p = e
e.z = c
e.u = c
e.t = c
e.p = m
n.u = f
n.s = c
m.z = c
m.u = c
m.t = c
m.p = g
g.z = c
g.u = c
g.t = c
g.p = f
assert m.p.p.t.q.txt == "e"