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

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

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

e = A("e")
a = B("a")
c = C("c")
d = A("d")
h = A("h")
b = B("b")
n = A("n")

e.y = n
e.p = b
a.p = c
a.v = b
a.s = b
c.q = n
c.y = n
d.y = h
d.p = a
h.y = n
h.p = b
b.p = c
b.v = a
b.s = a
n.y = e
n.p = a
assert c.q.p.p.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: B = None
        self.txt = txt

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

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

e = A("e")
a = B("a")
c = C("c")
d = A("d")
h = A("h")
b = B("b")
n = A("n")

e.y = n
e.p = b
a.p = c
a.v = b
a.s = b
c.q = n
c.y = n
d.y = h
d.p = a
h.y = n
h.p = b
b.p = c
b.v = a
b.s = a
n.y = e
n.p = a
assert c.q.p.p.q.y.txt == "e"