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

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

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

h = A("h")
g = B("g")
j = C("j")
k = A("k")
d = B("d")

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

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

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

h = A("h")
g = B("g")
j = C("j")
k = A("k")
d = B("d")

h.x = g
h.s = k
h.y = d
g.z = j
g.s = h
j.u = k
k.x = g
k.s = h
k.y = d
d.z = j
d.s = h
assert j.u.x.s.s.txt == "k"