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

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

d = A("d")
l = B("l")
k = B("k")
i = B("i")
e = A("e")
n = B("n")
j = B("j")
h = A("h")
a = B("a")

d.v = h
l.q = k
k.q = i
i.q = n
e.v = h
n.q = l
j.q = l
h.v = d
a.q = n
assert j.q.q.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

d = A("d")
l = B("l")
k = B("k")
i = B("i")
e = A("e")
n = B("n")
j = B("j")
h = A("h")
a = B("a")

d.v = h
l.q = k
k.q = i
i.q = n
e.v = h
n.q = l
j.q = l
h.v = d
a.q = n
assert j.q.q.q.q.q.q.q.q.txt == "n"