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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.o: C = None
        self.y: D = None
        self.x: D = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.o: C = None
        self.y: D = None
        self.x: D = None
        self.txt = txt

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

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

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

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