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

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

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

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

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

l.s = n
j.o = i
a.t = m
a.y = j
a.q = i
m.p = l
n.s = l
i.t = m
i.y = j
i.q = a
assert j.o.t.p.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

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

l.s = n
j.o = i
a.t = m
a.y = j
a.q = i
m.p = l
n.s = l
i.t = m
i.y = j
i.q = a
assert j.o.t.p.s.s.txt == "l"