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

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

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

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

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

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

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

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

j.s = l
j.w = g
j.x = g
g.u = a
l.p = j
l.r = g
a.s = l
a.w = g
a.x = g
assert g.u.s.r.u.txt == "a"