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

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

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

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

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

f.w = a
b.o = d
g.u = d
g.w = a
i.p = m
i.v = m
i.w = f
i.y = d
d.p = b
d.v = b
d.w = n
d.y = i
a.u = i
a.w = g
m.o = d
l.w = g
n.w = a
assert f.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

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

f.w = a
b.o = d
g.u = d
g.w = a
i.p = m
i.v = m
i.w = f
i.y = d
d.p = b
d.v = b
d.w = n
d.y = i
a.u = i
a.w = g
m.o = d
l.w = g
n.w = a
assert f.w.u.w.txt == "f"