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

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

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

h = A("h")
m = B("m")
g = C("g")
n = C("n")
b = B("b")
d = B("d")
l = A("l")
k = B("k")

h.x = g
h.p = n
m.u = h
m.r = g
m.v = d
g.w = n
g.y = h
g.o = d
n.w = g
n.y = h
n.o = b
b.u = l
b.r = n
b.v = d
d.u = h
d.r = n
d.v = k
l.x = g
l.p = n
k.u = h
k.r = n
k.v = m
assert h.x.o.r.o.r.y.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: C = None
        self.txt = txt

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

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

h = A("h")
m = B("m")
g = C("g")
n = C("n")
b = B("b")
d = B("d")
l = A("l")
k = B("k")

h.x = g
h.p = n
m.u = h
m.r = g
m.v = d
g.w = n
g.y = h
g.o = d
n.w = g
n.y = h
n.o = b
b.u = l
b.r = n
b.v = d
d.u = h
d.r = n
d.v = k
l.x = g
l.p = n
k.u = h
k.r = n
k.v = m
assert h.x.o.r.o.r.y.x.w.txt == "n"