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

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

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

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

l = A("l")
i = B("i")
e = C("e")
m = D("m")

l.t = e
l.p = i
i.x = l
e.s = m
m.s = e
assert e.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: B = None
        self.txt = txt

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

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

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

l = A("l")
i = B("i")
e = C("e")
m = D("m")

l.t = e
l.p = i
i.x = l
e.s = m
m.s = e
assert e.s.s.s.txt == "m"