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

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

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

l = A("l")
i = B("i")
f = C("f")
e = C("e")
c = B("c")
a = C("a")
h = B("h")
j = A("j")
b = A("b")

l.u = f
i.y = h
i.s = j
f.t = e
f.w = b
e.t = a
e.w = b
c.y = h
c.s = j
a.t = f
a.w = b
h.y = i
h.s = j
j.u = a
b.u = f
assert b.u.t.w.u.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

l = A("l")
i = B("i")
f = C("f")
e = C("e")
c = B("c")
a = C("a")
h = B("h")
j = A("j")
b = A("b")

l.u = f
i.y = h
i.s = j
f.t = e
f.w = b
e.t = a
e.w = b
c.y = h
c.s = j
a.t = f
a.w = b
h.y = i
h.s = j
j.u = a
b.u = f
assert b.u.t.w.u.w.u.txt == "f"