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

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

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

e = A("e")
k = B("k")
f = C("f")
i = B("i")

e.s = f
k.p = i
f.q = i
f.o = i
i.p = k
assert i.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

e = A("e")
k = B("k")
f = C("f")
i = B("i")

e.s = f
k.p = i
f.q = i
f.o = i
i.p = k
assert i.p.p.p.txt == "k"