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

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

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

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

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

c.q = e
k.q = c
m.v = k
m.p = a
n.y = g
g.v = k
g.p = a
i.y = e
e.v = k
e.p = a
b.y = m
a.q = m
assert c.q.v.q.q.p.q.v.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

c.q = e
k.q = c
m.v = k
m.p = a
n.y = g
g.v = k
g.p = a
i.y = e
e.v = k
e.p = a
b.y = m
a.q = m
assert c.q.v.q.q.p.q.v.q.q.txt == "e"