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

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

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

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

l.y = b
l.v = d
b.o = f
f.t = l
f.s = l
f.y = d
d.o = f
assert f.t.v.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: B = None
        self.txt = txt

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

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

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

l.y = b
l.v = d
b.o = f
f.t = l
f.s = l
f.y = d
d.o = f
assert f.t.v.o.s.txt == "l"