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

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

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

j = A("j")
l = B("l")
g = C("g")
c = A("c")
a = A("a")

j.s = l
j.x = a
j.u = a
l.r = j
g.y = l
c.s = l
c.x = a
c.u = j
a.s = l
a.x = c
a.u = j
assert c.s.r.s.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: A = None
        self.u: A = None
        self.txt = txt

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

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

j = A("j")
l = B("l")
g = C("g")
c = A("c")
a = A("a")

j.s = l
j.x = a
j.u = a
l.r = j
g.y = l
c.s = l
c.x = a
c.u = j
a.s = l
a.x = c
a.u = j
assert c.s.r.s.r.x.txt == "a"