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

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

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

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

i = A("i")
b = B("b")
h = C("h")
a = D("a")
d = B("d")
c = A("c")
m = C("m")
n = B("n")

i.r = a
i.z = h
b.u = n
b.s = a
b.v = d
h.w = a
h.r = m
h.v = m
h.s = c
a.q = h
a.z = h
d.u = b
d.s = a
d.v = n
c.r = a
c.z = m
m.w = a
m.r = h
m.v = h
m.s = i
n.u = b
n.s = a
n.v = d
assert h.r.v.v.w.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.z: C = None
        self.txt = txt

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

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

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

i = A("i")
b = B("b")
h = C("h")
a = D("a")
d = B("d")
c = A("c")
m = C("m")
n = B("n")

i.r = a
i.z = h
b.u = n
b.s = a
b.v = d
h.w = a
h.r = m
h.v = m
h.s = c
a.q = h
a.z = h
d.u = b
d.s = a
d.v = n
c.r = a
c.z = m
m.w = a
m.r = h
m.v = h
m.s = i
n.u = b
n.s = a
n.v = d
assert h.r.v.v.w.q.w.txt == "a"