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

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.t: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.q: C = None
        self.z: A = None
        self.txt = txt

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

n.q = a
d.o = j
d.t = k
h.q = j
h.p = j
h.r = k
h.v = f
j.s = h
j.q = k
j.z = a
b.s = k
b.q = k
b.z = n
a.q = f
c.o = j
c.t = k
e.q = a
k.q = j
k.p = j
k.r = h
k.v = n
f.q = e
assert a.q.q.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.t: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.q: C = None
        self.z: A = None
        self.txt = txt

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

n.q = a
d.o = j
d.t = k
h.q = j
h.p = j
h.r = k
h.v = f
j.s = h
j.q = k
j.z = a
b.s = k
b.q = k
b.z = n
a.q = f
c.o = j
c.t = k
e.q = a
k.q = j
k.p = j
k.r = h
k.v = n
f.q = e
assert a.q.q.q.q.q.q.q.q.txt == "e"