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

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

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

n = A("n")
m = B("m")
g = C("g")
b = C("b")
e = B("e")
i = C("i")
d = C("d")
j = A("j")
k = B("k")
h = A("h")

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

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

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

n = A("n")
m = B("m")
g = C("g")
b = C("b")
e = B("e")
i = C("i")
d = C("d")
j = A("j")
k = B("k")
h = A("h")

n.p = b
m.x = n
m.y = i
g.u = j
g.o = k
b.u = n
b.o = e
e.x = j
e.y = b
i.u = n
i.o = k
d.u = j
d.o = e
j.p = i
k.x = n
k.y = g
h.p = b
assert d.o.x.p.u.p.o.y.u.p.o.txt == "e"