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

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

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

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

n.x = d
n.r = h
n.w = a
m.y = c
m.o = i
m.z = b
b.u = i
b.r = i
b.q = c
i.x = d
i.r = c
i.w = n
d.y = c
d.z = c
d.o = i
h.u = a
h.q = b
h.r = n
c.u = n
c.q = h
c.r = a
e.y = c
e.o = i
e.z = h
a.x = m
a.r = c
a.w = i
assert i.x.y.q.q.r.w.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: C = None
        self.w: A = None
        self.txt = txt

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

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

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

n.x = d
n.r = h
n.w = a
m.y = c
m.o = i
m.z = b
b.u = i
b.r = i
b.q = c
i.x = d
i.r = c
i.w = n
d.y = c
d.z = c
d.o = i
h.u = a
h.q = b
h.r = n
c.u = n
c.q = h
c.r = a
e.y = c
e.o = i
e.z = h
a.x = m
a.r = c
a.w = i
assert i.x.y.q.q.r.w.r.r.txt == "n"