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

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: G = None
        self.t: F = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: F = None
        self.z: A = None
        self.q: C = None
        self.txt = txt

d = A("d")
g = B("g")
k = C("k")
c = D("c")
i = E("i")
e = F("e")
h = G("h")
l = F("l")
a = E("a")
n = D("n")

d.q = i
g.p = n
k.q = g
c.p = d
i.o = h
i.t = l
e.p = k
h.v = n
h.y = e
h.z = d
h.q = k
l.p = k
a.o = h
a.t = l
n.p = d
assert c.p.q.o.y.p.q.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: G = None
        self.t: F = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: F = None
        self.z: A = None
        self.q: C = None
        self.txt = txt

d = A("d")
g = B("g")
k = C("k")
c = D("c")
i = E("i")
e = F("e")
h = G("h")
l = F("l")
a = E("a")
n = D("n")

d.q = i
g.p = n
k.q = g
c.p = d
i.o = h
i.t = l
e.p = k
h.v = n
h.y = e
h.z = d
h.q = k
l.p = k
a.o = h
a.t = l
n.p = d
assert c.p.q.o.y.p.q.p.p.txt == "d"