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

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

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

h = A("h")
m = B("m")
k = C("k")
b = C("b")
c = B("c")
l = B("l")

h.u = m
h.w = l
m.z = c
m.p = c
m.y = b
k.s = m
k.q = h
b.s = c
b.q = h
c.z = l
c.y = k
c.p = m
l.z = m
l.p = m
l.y = b
assert h.w.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: B = None
        self.txt = txt

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

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

h = A("h")
m = B("m")
k = C("k")
b = C("b")
c = B("c")
l = B("l")

h.u = m
h.w = l
m.z = c
m.p = c
m.y = b
k.s = m
k.q = h
b.s = c
b.q = h
c.z = l
c.y = k
c.p = m
l.z = m
l.p = m
l.y = b
assert h.w.y.q.txt == "h"