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

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

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

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

g.u = j
k.x = j
j.w = k
j.x = k
assert k.x.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

g.u = j
k.x = j
j.w = k
j.x = k
assert k.x.w.x.txt == "j"