class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: A = None
        self.txt = txt

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

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

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

g.v = k
g.w = k
h.x = e
h.s = e
h.u = j
e.u = m
m.u = e
k.v = g
k.w = g
j.x = e
j.u = h
j.s = m
assert k.v.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: A = None
        self.txt = txt

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

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

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

g.v = k
g.w = k
h.x = e
h.s = e
h.u = j
e.u = m
m.u = e
k.v = g
k.w = g
j.x = e
j.u = h
j.s = m
assert k.v.w.w.txt == "g"