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

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

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

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

i = A("i")
b = B("b")
e = C("e")
n = D("n")

i.s = b
i.y = e
b.q = i
e.r = i
n.t = e
assert n.t.r.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: C = None
        self.txt = txt

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

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

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

i = A("i")
b = B("b")
e = C("e")
n = D("n")

i.s = b
i.y = e
b.q = i
e.r = i
n.t = e
assert n.t.r.s.q.txt == "i"