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

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

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

b = A("b")
i = B("i")
h = C("h")
m = A("m")
e = B("e")
a = C("a")
l = A("l")

b.p = h
b.s = e
b.q = l
i.w = h
i.q = b
i.p = a
h.z = a
h.v = l
m.p = a
m.s = i
m.q = l
e.w = a
e.q = m
e.p = h
a.z = h
a.v = b
l.p = h
l.s = i
l.q = m
assert a.v.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: B = None
        self.q: A = None
        self.txt = txt

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

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

b = A("b")
i = B("i")
h = C("h")
m = A("m")
e = B("e")
a = C("a")
l = A("l")

b.p = h
b.s = e
b.q = l
i.w = h
i.q = b
i.p = a
h.z = a
h.v = l
m.p = a
m.s = i
m.q = l
e.w = a
e.q = m
e.p = h
a.z = h
a.v = b
l.p = h
l.s = i
l.q = m
assert a.v.p.z.txt == "a"