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

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

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

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

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

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

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

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

c.y = a
c.o = l
a.p = c
a.o = l
a.v = l
l.w = c
l.r = c
l.v = a
assert l.r.y.p.txt == "c"