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

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

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

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

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

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

b.u = n
b.x = n
b.v = f
b.p = e
f.q = b
f.v = m
i.o = f
i.v = m
n.o = m
n.v = i
m.o = i
m.y = b
e.q = b
e.v = m
assert n.o.o.v.y.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.v: B = None
        self.x: D = None
        self.p: B = None
        self.txt = txt

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

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

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

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

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

b.u = n
b.x = n
b.v = f
b.p = e
f.q = b
f.v = m
i.o = f
i.v = m
n.o = m
n.v = i
m.o = i
m.y = b
e.q = b
e.v = m
assert n.o.o.v.y.p.q.txt == "b"