class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: C = None
        self.o: B = None
        self.txt = txt

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

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

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

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

m.q = c
m.v = c
m.o = h
h.q = n
h.s = e
h.y = m
h.x = m
c.p = m
c.x = m
c.v = m
c.t = h
e.o = c
n.p = m
n.x = m
n.v = m
n.t = h
assert h.x.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: C = None
        self.o: B = None
        self.txt = txt

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

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

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

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

m.q = c
m.v = c
m.o = h
h.q = n
h.s = e
h.y = m
h.x = m
c.p = m
c.x = m
c.v = m
c.t = h
e.o = c
n.p = m
n.x = m
n.v = m
n.t = h
assert h.x.o.q.txt == "n"