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

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

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

n = A("n")
c = B("c")
f = C("f")
a = B("a")
i = A("i")
m = B("m")
h = B("h")
d = A("d")
g = B("g")
b = A("b")

n.x = i
n.o = f
c.u = g
c.q = a
f.w = d
f.p = m
f.o = b
a.u = g
a.q = h
i.x = n
i.o = f
m.u = h
m.q = h
h.u = a
h.q = g
d.x = b
d.o = f
g.u = c
g.q = c
b.x = d
b.o = f
assert h.u.q.u.q.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: C = None
        self.txt = txt

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

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

n = A("n")
c = B("c")
f = C("f")
a = B("a")
i = A("i")
m = B("m")
h = B("h")
d = A("d")
g = B("g")
b = A("b")

n.x = i
n.o = f
c.u = g
c.q = a
f.w = d
f.p = m
f.o = b
a.u = g
a.q = h
i.x = n
i.o = f
m.u = h
m.q = h
h.u = a
h.q = g
d.x = b
d.o = f
g.u = c
g.q = c
b.x = d
b.o = f
assert h.u.q.u.q.q.u.txt == "c"