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

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

d = A("d")
m = B("m")
i = C("i")
c = D("c")
g = B("g")
b = D("b")
a = A("a")
f = C("f")

d.w = c
d.o = g
d.z = m
m.w = i
m.y = c
i.u = c
i.x = d
c.o = i
g.w = f
g.y = b
b.o = i
a.w = b
a.o = m
a.z = m
f.u = c
f.x = a
assert c.o.u.o.u.o.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.o: B = None
        self.z: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

d = A("d")
m = B("m")
i = C("i")
c = D("c")
g = B("g")
b = D("b")
a = A("a")
f = C("f")

d.w = c
d.o = g
d.z = m
m.w = i
m.y = c
i.u = c
i.x = d
c.o = i
g.w = f
g.y = b
b.o = i
a.w = b
a.o = m
a.z = m
f.u = c
f.x = a
assert c.o.u.o.u.o.u.o.txt == "i"