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

class B:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: C = None
        self.z: C = 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.z: C = None
        self.t: A = None
        self.txt = txt

k = A("k")
l = B("l")
c = C("c")
j = D("j")
g = A("g")
a = D("a")
m = A("m")

k.t = j
k.q = c
l.w = a
l.q = c
l.z = c
c.v = k
j.z = c
j.t = g
g.t = j
g.q = c
a.z = c
a.t = k
m.t = j
m.q = c
assert k.q.v.q.v.t.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: C = None
        self.z: C = 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.z: C = None
        self.t: A = None
        self.txt = txt

k = A("k")
l = B("l")
c = C("c")
j = D("j")
g = A("g")
a = D("a")
m = A("m")

k.t = j
k.q = c
l.w = a
l.q = c
l.z = c
c.v = k
j.z = c
j.t = g
g.t = j
g.q = c
a.z = c
a.t = k
m.t = j
m.q = c
assert k.q.v.q.v.t.z.v.txt == "k"