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

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

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

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

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

b.v = h
b.q = f
c.x = e
c.p = b
c.o = h
l.v = f
h.u = m
h.z = d
j.u = l
j.z = n
f.v = j
f.q = b
d.x = h
d.p = b
d.o = j
m.v = b
e.u = m
e.z = n
n.x = j
n.o = j
n.p = f
assert m.v.v.z.o.z.p.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.q: A = None
        self.txt = txt

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

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

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

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

b.v = h
b.q = f
c.x = e
c.p = b
c.o = h
l.v = f
h.u = m
h.z = d
j.u = l
j.z = n
f.v = j
f.q = b
d.x = h
d.p = b
d.o = j
m.v = b
e.u = m
e.z = n
n.x = j
n.o = j
n.p = f
assert m.v.v.z.o.z.p.v.z.txt == "n"