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

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

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

h = A("h")
c = B("c")
n = C("n")
a = C("a")

h.p = a
h.v = n
c.s = n
c.z = n
c.t = a
n.t = c
n.q = a
a.t = c
a.q = n
assert n.q.q.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: C = None
        self.txt = txt

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

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

h = A("h")
c = B("c")
n = C("n")
a = C("a")

h.p = a
h.v = n
c.s = n
c.z = n
c.t = a
n.t = c
n.q = a
a.t = c
a.q = n
assert n.q.q.t.t.txt == "a"