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

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

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

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

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

n.v = c
n.u = c
n.z = a
m.t = n
m.w = h
a.x = h
a.o = c
a.t = m
h.q = d
h.x = m
c.v = n
c.u = n
c.z = a
d.q = h
d.x = m
assert m.t.z.x.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: C = None
        self.u: A = None
        self.txt = txt

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

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

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

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

n.v = c
n.u = c
n.z = a
m.t = n
m.w = h
a.x = h
a.o = c
a.t = m
h.q = d
h.x = m
c.v = n
c.u = n
c.z = a
d.q = h
d.x = m
assert m.t.z.x.x.w.txt == "h"