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

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

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

h = A("h")
e = B("e")
n = C("n")
c = B("c")
a = B("a")
b = C("b")
k = A("k")
j = A("j")

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

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

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

h = A("h")
e = B("e")
n = C("n")
c = B("c")
a = B("a")
b = C("b")
k = A("k")
j = A("j")

h.q = b
h.u = b
h.o = e
e.u = a
e.x = a
n.v = a
n.s = j
c.u = e
c.x = e
a.u = e
a.x = e
b.v = e
b.s = h
k.q = n
k.u = n
k.o = e
j.q = b
j.o = c
j.u = n
assert n.v.x.u.u.x.txt == "a"