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

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: C = None
        self.r: E = None
        self.s: A = None
        self.v: A = None
        self.txt = txt

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

g = A("g")
a = B("a")
m = C("m")
b = D("b")
e = E("e")
f = B("f")

g.o = e
a.q = g
a.x = g
a.y = e
m.p = g
m.r = b
b.p = m
b.u = m
b.r = e
b.s = g
b.v = g
e.q = b
f.q = g
f.x = g
f.y = e
assert f.y.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: C = None
        self.r: E = None
        self.s: A = None
        self.v: A = None
        self.txt = txt

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

g = A("g")
a = B("a")
m = C("m")
b = D("b")
e = E("e")
f = B("f")

g.o = e
a.q = g
a.x = g
a.y = e
m.p = g
m.r = b
b.p = m
b.u = m
b.r = e
b.s = g
b.v = g
e.q = b
f.q = g
f.x = g
f.y = e
assert f.y.q.v.txt == "g"