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

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

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

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

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

k.w = i
n.x = i
f.t = k
f.s = i
i.r = k
i.q = n
assert n.x.q.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

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

k.w = i
n.x = i
f.t = k
f.s = i
i.r = k
i.q = n
assert n.x.q.x.q.txt == "n"