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

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

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

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

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

f = A("f")
b = B("b")
n = C("n")
d = D("d")
e = E("e")
i = D("i")
m = E("m")
g = C("g")
k = C("k")

f.o = m
b.p = k
n.v = b
d.w = i
d.o = i
d.x = m
d.p = f
e.w = m
e.p = f
i.w = d
i.o = d
i.x = e
i.p = f
m.w = e
m.p = f
g.v = b
k.v = b
assert f.o.w.p.o.p.o.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

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

f = A("f")
b = B("b")
n = C("n")
d = D("d")
e = E("e")
i = D("i")
m = E("m")
g = C("g")
k = C("k")

f.o = m
b.p = k
n.v = b
d.w = i
d.o = i
d.x = m
d.p = f
e.w = m
e.p = f
i.w = d
i.o = d
i.x = e
i.p = f
m.w = e
m.p = f
g.v = b
k.v = b
assert f.o.w.p.o.p.o.p.o.txt == "m"