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

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

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

j = A("j")
m = B("m")
b = C("b")
h = B("h")
a = C("a")

j.z = m
j.x = m
j.w = b
m.r = b
m.s = b
m.y = h
b.z = j
b.q = j
b.y = a
h.r = a
h.s = b
h.y = m
a.z = j
a.q = j
a.y = b
assert a.y.y.y.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: B = None
        self.w: C = None
        self.txt = txt

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

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

j = A("j")
m = B("m")
b = C("b")
h = B("h")
a = C("a")

j.z = m
j.x = m
j.w = b
m.r = b
m.s = b
m.y = h
b.z = j
b.q = j
b.y = a
h.r = a
h.s = b
h.y = m
a.z = j
a.q = j
a.y = b
assert a.y.y.y.y.z.txt == "j"