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

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

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

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

j = A("j")
g = B("g")
d = C("d")
b = D("b")
a = C("a")
h = C("h")
l = B("l")
n = D("n")
k = B("k")

j.t = b
j.q = d
j.u = d
g.p = l
g.z = j
d.z = j
b.v = j
a.z = j
h.z = j
l.p = k
l.z = j
n.v = j
k.p = g
k.z = j
assert j.t.v.t.v.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.q: C = None
        self.u: C = None
        self.txt = txt

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

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

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

j = A("j")
g = B("g")
d = C("d")
b = D("b")
a = C("a")
h = C("h")
l = B("l")
n = D("n")
k = B("k")

j.t = b
j.q = d
j.u = d
g.p = l
g.z = j
d.z = j
b.v = j
a.z = j
h.z = j
l.p = k
l.z = j
n.v = j
k.p = g
k.z = j
assert j.t.v.t.v.t.v.txt == "j"