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

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

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

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

h.p = l
h.o = l
f.u = b
f.x = b
c.t = b
c.u = f
e.p = l
e.o = l
b.u = f
b.x = f
m.t = f
m.u = f
l.p = h
l.o = e
assert m.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: A = None
        self.txt = txt

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

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

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

h.p = l
h.o = l
f.u = b
f.x = b
c.t = b
c.u = f
e.p = l
e.o = l
b.u = f
b.x = f
m.t = f
m.u = f
l.p = h
l.o = e
assert m.u.u.u.u.u.txt == "f"