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

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

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

c = A("c")
l = B("l")
b = C("b")
d = B("d")

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

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

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

c = A("c")
l = B("l")
b = C("b")
d = B("d")

c.o = b
c.r = b
l.r = b
b.v = c
b.w = c
b.y = c
d.r = b
assert b.y.r.v.r.txt == "b"