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.r: A = None
        self.u: A = None
        self.p: C = None
        self.txt = txt

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

c = A("c")
a = B("a")
k = C("k")
l = A("l")
b = C("b")

c.s = k
c.p = b
c.t = a
a.r = l
a.u = c
a.p = k
k.r = b
l.s = k
l.p = k
l.t = a
b.r = k
assert b.r.r.r.r.r.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.r: A = None
        self.u: A = None
        self.p: C = None
        self.txt = txt

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

c = A("c")
a = B("a")
k = C("k")
l = A("l")
b = C("b")

c.s = k
c.p = b
c.t = a
a.r = l
a.u = c
a.p = k
k.r = b
l.s = k
l.p = k
l.t = a
b.r = k
assert b.r.r.r.r.r.txt == "k"