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

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.t: A = None
        self.y: C = None
        self.w: D = None
        self.txt = txt

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

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

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

a.q = e
b.x = a
b.t = a
b.y = e
b.w = k
e.s = n
k.v = c
f.v = c
i.v = h
n.s = e
g.q = e
h.v = f
c.v = k
assert h.v.v.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.t: A = None
        self.y: C = None
        self.w: D = None
        self.txt = txt

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

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

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

a.q = e
b.x = a
b.t = a
b.y = e
b.w = k
e.s = n
k.v = c
f.v = c
i.v = h
n.s = e
g.q = e
h.v = f
c.v = k
assert h.v.v.v.v.v.v.v.v.txt == "c"