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

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

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

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

j = A("j")
n = B("n")
a = C("a")
b = D("b")
i = C("i")

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

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

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

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

j = A("j")
n = B("n")
a = C("a")
b = D("b")
i = C("i")

j.s = b
n.s = i
n.o = a
a.s = j
a.x = j
a.u = j
b.s = n
b.q = i
b.u = i
i.s = j
i.x = j
i.u = j
assert b.q.u.s.q.txt == "i"