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

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

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

n = A("n")
g = B("g")
b = C("b")
k = B("k")
c = B("c")
e = A("e")
f = A("f")
d = C("d")
h = A("h")
j = A("j")

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

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

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

n = A("n")
g = B("g")
b = C("b")
k = B("k")
c = B("c")
e = A("e")
f = A("f")
d = C("d")
h = A("h")
j = A("j")

n.v = e
n.q = j
g.u = k
b.w = h
b.v = g
k.u = g
c.u = k
e.v = f
e.q = f
f.v = e
f.q = j
d.w = h
d.v = k
h.v = j
h.q = e
j.v = f
j.q = f
assert h.q.v.v.q.v.q.q.txt == "j"