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

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: A = None
        self.txt = txt

f = A("f")
d = B("d")
b = C("b")
i = D("i")
h = E("h")
n = E("n")
a = E("a")
m = A("m")

f.z = h
f.o = i
d.v = n
d.z = b
b.w = m
b.y = f
i.w = f
h.q = f
h.r = f
n.q = m
n.r = m
a.q = m
a.r = f
m.z = n
m.o = i
assert f.o.w.z.q.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.o: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: A = None
        self.txt = txt

f = A("f")
d = B("d")
b = C("b")
i = D("i")
h = E("h")
n = E("n")
a = E("a")
m = A("m")

f.z = h
f.o = i
d.v = n
d.z = b
b.w = m
b.y = f
i.w = f
h.q = f
h.r = f
n.q = m
n.r = m
a.q = m
a.r = f
m.z = n
m.o = i
assert f.o.w.z.q.z.q.txt == "f"