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

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

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

f = A("f")
m = B("m")
i = C("i")
g = A("g")
n = C("n")
l = B("l")

f.w = n
m.w = n
m.r = g
i.v = n
i.u = n
i.z = n
g.w = i
n.v = i
n.u = i
n.z = i
l.w = n
l.r = f
assert n.u.u.v.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
i = C("i")
g = A("g")
n = C("n")
l = B("l")

f.w = n
m.w = n
m.r = g
i.v = n
i.u = n
i.z = n
g.w = i
n.v = i
n.u = i
n.z = i
l.w = n
l.r = f
assert n.u.u.v.u.u.txt == "i"