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

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

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

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

f = A("f")
g = B("g")
i = C("i")
k = D("k")
c = C("c")
e = A("e")
a = C("a")
n = D("n")

f.r = e
f.o = e
f.w = g
f.y = n
g.u = e
g.x = n
i.x = f
k.s = g
k.u = e
k.r = c
k.z = f
c.x = e
e.r = f
e.o = f
e.w = g
e.y = n
a.x = e
n.s = g
n.u = e
n.r = a
n.z = f
assert i.x.w.x.u.w.u.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: A = None
        self.w: B = None
        self.y: D = None
        self.txt = txt

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

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

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

f = A("f")
g = B("g")
i = C("i")
k = D("k")
c = C("c")
e = A("e")
a = C("a")
n = D("n")

f.r = e
f.o = e
f.w = g
f.y = n
g.u = e
g.x = n
i.x = f
k.s = g
k.u = e
k.r = c
k.z = f
c.x = e
e.r = f
e.o = f
e.w = g
e.y = n
a.x = e
n.s = g
n.u = e
n.r = a
n.z = f
assert i.x.w.x.u.w.u.o.w.txt == "g"