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

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

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

n = A("n")
b = B("b")
h = C("h")
c = B("c")
f = A("f")
j = C("j")
g = B("g")
a = B("a")
e = A("e")
m = C("m")

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

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

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

n = A("n")
b = B("b")
h = C("h")
c = B("c")
f = A("f")
j = C("j")
g = B("g")
a = B("a")
e = A("e")
m = C("m")

n.u = m
n.v = f
b.x = g
b.o = j
b.q = e
h.v = j
h.w = g
c.x = g
c.o = j
c.q = e
f.u = m
f.v = n
j.v = h
j.w = b
g.x = b
g.o = j
g.q = f
a.x = g
a.o = j
a.q = f
e.u = m
e.v = n
m.v = j
m.w = g
assert n.u.v.w.o.v.w.o.v.w.q.txt == "f"