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

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

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

k = A("k")
j = B("j")
a = C("a")
b = B("b")

k.s = a
j.p = k
j.o = k
j.y = b
a.y = b
a.p = b
a.w = k
b.p = k
b.o = k
b.y = j
assert j.y.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

k = A("k")
j = B("j")
a = C("a")
b = B("b")

k.s = a
j.p = k
j.o = k
j.y = b
a.y = b
a.p = b
a.w = k
b.p = k
b.o = k
b.y = j
assert j.y.o.s.txt == "a"