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

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

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

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

j = A("j")
i = B("i")
g = C("g")
c = D("c")
h = C("h")
k = C("k")
a = A("a")
n = A("n")
l = B("l")

j.q = g
j.p = n
i.s = c
i.w = c
i.v = h
g.u = l
g.o = k
c.q = h
c.w = i
h.u = i
h.o = g
k.u = l
k.o = g
a.q = k
a.p = n
n.q = g
n.p = j
l.s = c
l.w = c
l.v = k
assert k.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: A = None
        self.txt = txt

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

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

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

j = A("j")
i = B("i")
g = C("g")
c = D("c")
h = C("h")
k = C("k")
a = A("a")
n = A("n")
l = B("l")

j.q = g
j.p = n
i.s = c
i.w = c
i.v = h
g.u = l
g.o = k
c.q = h
c.w = i
h.u = i
h.o = g
k.u = l
k.o = g
a.q = k
a.p = n
n.q = g
n.p = j
l.s = c
l.w = c
l.v = k
assert k.o.o.o.o.o.o.o.txt == "g"