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

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

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

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

n.s = l
n.z = j
d.r = l
d.x = n
a.t = j
a.x = d
j.r = l
j.x = l
i.t = j
i.x = j
l.s = n
l.z = j
assert j.x.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: B = None
        self.txt = txt

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

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

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

n.s = l
n.z = j
d.r = l
d.x = n
a.t = j
a.x = d
j.r = l
j.x = l
i.t = j
i.x = j
l.s = n
l.z = j
assert j.x.s.s.s.txt == "n"