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

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

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

i = A("i")
f = B("f")
j = C("j")
l = A("l")
m = C("m")

i.p = l
i.w = f
f.w = l
j.t = i
j.u = f
l.p = i
l.w = f
m.t = i
m.u = f
assert m.u.w.p.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.w: B = None
        self.txt = txt

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

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

i = A("i")
f = B("f")
j = C("j")
l = A("l")
m = C("m")

i.p = l
i.w = f
f.w = l
j.t = i
j.u = f
l.p = i
l.w = f
m.t = i
m.u = f
assert m.u.w.p.w.w.txt == "l"