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

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

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

e = A("e")
k = B("k")
f = C("f")
d = B("d")
g = B("g")
a = A("a")

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

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

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

e = A("e")
k = B("k")
f = C("f")
d = B("d")
g = B("g")
a = A("a")

e.y = d
e.u = k
k.y = g
k.z = f
k.x = f
f.s = e
f.t = e
d.y = g
d.z = f
d.x = f
g.y = k
g.z = f
g.x = f
a.y = d
a.u = g
assert g.y.z.t.y.x.t.txt == "e"