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

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

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

i = A("i")
j = B("j")
k = C("k")
f = B("f")
h = B("h")

i.w = k
j.p = i
k.q = j
f.p = i
h.p = i
assert f.p.w.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

i = A("i")
j = B("j")
k = C("k")
f = B("f")
h = B("h")

i.w = k
j.p = i
k.q = j
f.p = i
h.p = i
assert f.p.w.q.p.txt == "i"