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

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

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

c = A("c")
j = B("j")
l = C("l")
n = B("n")
a = C("a")

c.s = a
c.p = a
c.t = j
j.s = n
j.x = c
j.p = c
l.x = a
n.s = j
n.x = c
n.p = c
a.x = l
assert j.x.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.p: C = None
        self.t: B = None
        self.txt = txt

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

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

c = A("c")
j = B("j")
l = C("l")
n = B("n")
a = C("a")

c.s = a
c.p = a
c.t = j
j.s = n
j.x = c
j.p = c
l.x = a
n.s = j
n.x = c
n.p = c
a.x = l
assert j.x.t.s.txt == "n"