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

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

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

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

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

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

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

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

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

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

k.q = i
k.y = f
d.r = i
l.s = i
l.o = k
i.w = f
n.s = i
n.o = k
f.w = i
assert k.y.w.w.w.txt == "i"