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

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

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

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

k = A("k")
i = B("i")
l = C("l")
m = D("m")
n = A("n")
a = D("a")

k.z = i
k.t = n
i.p = k
l.z = k
l.t = n
m.r = k
m.q = a
n.z = i
n.t = k
a.r = n
a.q = m
assert l.z.z.p.t.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: A = None
        self.txt = txt

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

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

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

k = A("k")
i = B("i")
l = C("l")
m = D("m")
n = A("n")
a = D("a")

k.z = i
k.t = n
i.p = k
l.z = k
l.t = n
m.r = k
m.q = a
n.z = i
n.t = k
a.r = n
a.q = m
assert l.z.z.p.t.z.p.txt == "k"