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

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

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

f = A("f")
j = B("j")
l = C("l")
b = C("b")
a = B("a")
k = B("k")
h = A("h")
e = B("e")
m = C("m")

f.u = b
j.o = h
j.w = k
l.z = h
l.r = a
b.z = f
b.r = j
a.o = h
a.w = j
k.o = h
k.w = a
h.u = m
e.o = h
e.w = a
m.z = f
m.r = k
assert m.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

f = A("f")
j = B("j")
l = C("l")
b = C("b")
a = B("a")
k = B("k")
h = A("h")
e = B("e")
m = C("m")

f.u = b
j.o = h
j.w = k
l.z = h
l.r = a
b.z = f
b.r = j
a.o = h
a.w = j
k.o = h
k.w = a
h.u = m
e.o = h
e.w = a
m.z = f
m.r = k
assert m.z.u.z.txt == "f"