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

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

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

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

k = A("k")
i = B("i")
d = C("d")
h = D("h")
f = D("f")
c = B("c")
b = B("b")
a = C("a")

k.v = f
k.p = i
k.q = i
i.t = k
i.v = d
i.z = c
d.v = a
d.q = f
h.z = i
h.v = f
h.w = f
f.z = i
f.v = h
f.w = h
c.t = k
c.v = a
c.z = b
b.t = k
b.v = a
b.z = c
a.v = d
a.q = f
assert c.t.q.t.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.p: B = None
        self.q: B = None
        self.txt = txt

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

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

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

k = A("k")
i = B("i")
d = C("d")
h = D("h")
f = D("f")
c = B("c")
b = B("b")
a = C("a")

k.v = f
k.p = i
k.q = i
i.t = k
i.v = d
i.z = c
d.v = a
d.q = f
h.z = i
h.v = f
h.w = f
f.z = i
f.v = h
f.w = h
c.t = k
c.v = a
c.z = b
b.t = k
b.v = a
b.z = c
a.v = d
a.q = f
assert c.t.q.t.v.z.txt == "i"