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

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

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

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

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

m.z = l
l.v = k
g.x = h
g.t = e
g.v = m
c.p = n
c.v = l
c.q = h
e.v = c
k.p = n
k.v = e
k.q = h
h.p = n
h.v = l
h.q = c
n.x = c
n.t = e
n.v = m
f.z = e
assert c.v.v.p.x.q.v.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

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

m.z = l
l.v = k
g.x = h
g.t = e
g.v = m
c.p = n
c.v = l
c.q = h
e.v = c
k.p = n
k.v = e
k.q = h
h.p = n
h.v = l
h.q = c
n.x = c
n.t = e
n.v = m
f.z = e
assert c.v.v.p.x.q.v.v.p.txt == "n"