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

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

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

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

l.u = h
l.w = h
l.t = f
h.w = f
h.r = j
f.t = n
f.y = h
m.u = j
m.w = g
m.t = n
n.t = f
n.y = g
g.w = n
g.r = h
j.w = f
j.r = h
assert j.w.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: B = None
        self.t: C = None
        self.txt = txt

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

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

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

l.u = h
l.w = h
l.t = f
h.w = f
h.r = j
f.t = n
f.y = h
m.u = j
m.w = g
m.t = n
n.t = f
n.y = g
g.w = n
g.r = h
j.w = f
j.r = h
assert j.w.t.y.txt == "g"