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

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

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

m = A("m")
f = B("f")
h = C("h")
a = B("a")

m.o = f
m.y = h
f.o = a
f.u = a
f.x = m
h.u = a
h.t = f
a.o = f
a.u = f
a.x = m
assert f.x.o.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: C = None
        self.txt = txt

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

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

m = A("m")
f = B("f")
h = C("h")
a = B("a")

m.o = f
m.y = h
f.o = a
f.u = a
f.x = m
h.u = a
h.t = f
a.o = f
a.u = f
a.x = m
assert f.x.o.x.y.txt == "h"