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

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

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

c = A("c")
i = B("i")
f = C("f")
d = A("d")

c.v = f
i.o = c
f.o = i
f.p = i
f.s = c
d.v = f
assert i.o.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

c = A("c")
i = B("i")
f = C("f")
d = A("d")

c.v = f
i.o = c
f.o = i
f.p = i
f.s = c
d.v = f
assert i.o.v.s.v.txt == "f"