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

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

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

c = A("c")
k = B("k")
l = C("l")
f = A("f")

c.z = f
c.y = l
c.o = k
k.p = l
l.r = c
f.z = c
f.y = l
f.o = k
assert c.y.r.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.y: C = None
        self.o: B = None
        self.txt = txt

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

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

c = A("c")
k = B("k")
l = C("l")
f = A("f")

c.z = f
c.y = l
c.o = k
k.p = l
l.r = c
f.z = c
f.y = l
f.o = k
assert c.y.r.y.r.txt == "c"