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

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

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

f = A("f")
n = B("n")
d = C("d")

f.u = d
f.s = d
n.o = f
n.v = f
n.s = d
d.w = n
d.o = n
assert f.s.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.s: C = None
        self.txt = txt

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

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

f = A("f")
n = B("n")
d = C("d")

f.u = d
f.s = d
n.o = f
n.v = f
n.s = d
d.w = n
d.o = n
assert f.s.w.s.txt == "d"