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

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

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

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

m = A("m")
n = B("n")
h = C("h")
l = D("l")
g = C("g")
b = D("b")
j = B("j")
d = D("d")
i = A("i")

m.q = i
m.v = n
m.p = n
m.z = h
n.q = j
n.o = m
h.x = g
h.r = l
h.v = j
h.z = i
l.t = h
l.y = j
l.v = m
l.q = d
g.x = h
g.r = b
g.v = j
g.z = m
b.t = h
b.y = n
b.v = m
b.q = d
j.q = n
j.o = i
d.t = h
d.y = n
d.v = i
d.q = l
i.q = m
i.v = n
i.p = j
i.z = g
assert i.q.q.v.o.v.o.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: B = None
        self.p: B = None
        self.z: C = None
        self.txt = txt

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

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

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

m = A("m")
n = B("n")
h = C("h")
l = D("l")
g = C("g")
b = D("b")
j = B("j")
d = D("d")
i = A("i")

m.q = i
m.v = n
m.p = n
m.z = h
n.q = j
n.o = m
h.x = g
h.r = l
h.v = j
h.z = i
l.t = h
l.y = j
l.v = m
l.q = d
g.x = h
g.r = b
g.v = j
g.z = m
b.t = h
b.y = n
b.v = m
b.q = d
j.q = n
j.o = i
d.t = h
d.y = n
d.v = i
d.q = l
i.q = m
i.v = n
i.p = j
i.z = g
assert i.q.q.v.o.v.o.q.v.txt == "n"