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

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

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

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

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

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

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

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

g.w = m
g.y = m
g.x = k
m.r = j
k.y = j
k.u = g
k.x = g
j.y = k
j.u = g
j.x = g
assert j.x.y.r.y.txt == "k"