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

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

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

m = A("m")
e = B("e")
d = C("d")
h = B("h")
b = A("b")
f = A("f")

m.p = d
m.u = b
e.o = b
e.w = b
e.t = d
d.z = f
d.s = e
d.y = e
h.o = f
h.t = d
h.w = b
b.p = d
b.u = f
f.p = d
f.u = b
assert f.u.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: A = None
        self.txt = txt

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

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

m = A("m")
e = B("e")
d = C("d")
h = B("h")
b = A("b")
f = A("f")

m.p = d
m.u = b
e.o = b
e.w = b
e.t = d
d.z = f
d.s = e
d.y = e
h.o = f
h.t = d
h.w = b
b.p = d
b.u = f
f.p = d
f.u = b
assert f.u.u.p.txt == "d"