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

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

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

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

h = A("h")
m = B("m")
d = C("d")
f = D("f")
e = B("e")
i = C("i")
j = C("j")
c = D("c")
g = C("g")

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

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

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

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

h = A("h")
m = B("m")
d = C("d")
f = D("f")
e = B("e")
i = C("i")
j = C("j")
c = D("c")
g = C("g")

h.z = d
h.u = e
m.z = h
m.t = e
d.w = c
d.z = j
d.q = e
d.x = i
f.z = g
f.t = c
f.x = j
e.z = h
e.t = m
i.w = c
i.z = g
i.q = m
i.x = d
j.w = c
j.z = i
j.q = m
j.x = d
c.z = d
c.t = f
c.x = j
g.w = f
g.z = d
g.x = d
g.q = e
assert j.w.t.x.w.txt == "c"