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

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

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

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

m.p = i
m.r = i
m.u = h
h.o = i
f.z = i
f.w = k
f.y = h
k.z = i
k.w = f
k.y = h
i.p = m
i.r = m
i.u = h
assert m.u.o.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.r: A = None
        self.u: B = None
        self.txt = txt

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

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

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

m.p = i
m.r = i
m.u = h
h.o = i
f.z = i
f.w = k
f.y = h
k.z = i
k.w = f
k.y = h
i.p = m
i.r = m
i.u = h
assert m.u.o.u.o.txt == "i"