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

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

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

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

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

k.t = l
i.o = g
i.q = l
i.p = l
i.w = k
g.p = n
g.z = n
g.x = k
l.t = k
l.r = k
n.p = g
n.z = g
n.x = k
assert n.p.z.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

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

k.t = l
i.o = g
i.q = l
i.p = l
i.w = k
g.p = n
g.z = n
g.x = k
l.t = k
l.r = k
n.p = g
n.z = g
n.x = k
assert n.p.z.x.t.t.txt == "k"