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

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

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

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

c = A("c")
j = B("j")
b = C("b")
a = D("a")
h = A("h")
f = A("f")
e = C("e")
g = A("g")

c.z = h
c.q = b
c.p = j
j.q = f
b.p = a
b.q = a
b.y = a
b.v = a
a.v = g
a.s = b
h.z = c
h.q = b
h.p = j
f.z = g
f.q = e
f.p = j
e.p = a
e.q = a
e.y = a
e.v = a
g.z = c
g.q = e
g.p = j
assert a.v.q.q.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.q: C = None
        self.p: B = None
        self.txt = txt

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

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

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

c = A("c")
j = B("j")
b = C("b")
a = D("a")
h = A("h")
f = A("f")
e = C("e")
g = A("g")

c.z = h
c.q = b
c.p = j
j.q = f
b.p = a
b.q = a
b.y = a
b.v = a
a.v = g
a.s = b
h.z = c
h.q = b
h.p = j
f.z = g
f.q = e
f.p = j
e.p = a
e.q = a
e.y = a
e.v = a
g.z = c
g.q = e
g.p = j
assert a.v.q.q.s.v.txt == "a"