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

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

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

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

l.t = g
l.w = k
k.v = g
k.x = l
k.p = m
j.w = m
j.u = l
j.q = g
m.w = j
m.u = l
m.q = g
h.t = l
h.w = k
g.t = h
g.w = k
assert m.w.u.t.w.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.w: B = None
        self.txt = txt

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

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

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

l.t = g
l.w = k
k.v = g
k.x = l
k.p = m
j.w = m
j.u = l
j.q = g
m.w = j
m.u = l
m.q = g
h.t = l
h.w = k
g.t = h
g.w = k
assert m.w.u.t.w.v.w.txt == "k"