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

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

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

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

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

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

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

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

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

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

l.y = d
l.p = d
l.x = m
l.z = i
h.z = d
h.t = i
h.v = e
h.x = g
c.t = n
c.x = l
c.u = l
c.s = h
g.q = d
g.w = l
f.q = l
f.w = l
i.q = d
i.w = d
e.t = n
e.s = n
e.x = l
e.u = l
d.y = l
d.p = l
d.x = h
d.z = f
m.z = l
m.t = g
m.v = c
m.x = f
n.z = d
n.t = g
n.v = c
n.x = i
assert g.w.z.w.x.txt == "h"