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

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

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

f = A("f")
d = B("d")
i = C("i")
e = A("e")
j = A("j")

f.w = i
d.u = e
i.p = d
e.w = i
j.w = i
assert f.w.p.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
i = C("i")
e = A("e")
j = A("j")

f.w = i
d.u = e
i.p = d
e.w = i
j.w = i
assert f.w.p.u.w.txt == "i"