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

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

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

l = A("l")
g = B("g")
h = C("h")

l.z = h
l.s = h
l.u = g
g.y = h
h.y = l
h.x = l
h.z = g
assert g.y.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: B = None
        self.s: C = None
        self.txt = txt

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

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

l = A("l")
g = B("g")
h = C("h")

l.z = h
l.s = h
l.u = g
g.y = h
h.y = l
h.x = l
h.z = g
assert g.y.z.y.txt == "h"