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

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

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

j = A("j")
g = B("g")
c = C("c")
a = C("a")
n = B("n")
k = B("k")
b = A("b")
f = C("f")

j.u = b
g.z = b
g.o = b
g.w = a
c.z = a
c.u = k
a.z = f
a.u = g
n.z = b
n.w = f
n.o = j
k.z = j
k.o = j
k.w = a
b.u = j
f.z = c
f.u = g
assert f.z.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

j = A("j")
g = B("g")
c = C("c")
a = C("a")
n = B("n")
k = B("k")
b = A("b")
f = C("f")

j.u = b
g.z = b
g.o = b
g.w = a
c.z = a
c.u = k
a.z = f
a.u = g
n.z = b
n.w = f
n.o = j
k.z = j
k.o = j
k.w = a
b.u = j
f.z = c
f.u = g
assert f.z.u.o.txt == "j"