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

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

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

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

a = A("a")
h = B("h")
n = C("n")
i = D("i")

a.r = i
a.u = i
h.o = i
h.w = a
n.r = i
n.q = a
n.s = h
i.w = n
assert i.w.q.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: D = None
        self.txt = txt

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

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

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

a = A("a")
h = B("h")
n = C("n")
i = D("i")

a.r = i
a.u = i
h.o = i
h.w = a
n.r = i
n.q = a
n.s = h
i.w = n
assert i.w.q.r.w.txt == "n"