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

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

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

g = A("g")
b = B("b")
f = C("f")
a = A("a")
m = B("m")

g.s = b
g.u = f
g.x = a
b.p = m
b.t = g
b.z = f
f.r = g
a.s = b
a.u = f
a.x = g
m.p = b
m.t = a
m.z = f
assert a.x.u.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.u: C = None
        self.x: A = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
f = C("f")
a = A("a")
m = B("m")

g.s = b
g.u = f
g.x = a
b.p = m
b.t = g
b.z = f
f.r = g
a.s = b
a.u = f
a.x = g
m.p = b
m.t = a
m.z = f
assert a.x.u.r.s.txt == "b"