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

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

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

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

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

m = A("m")
g = B("g")
c = C("c")
f = D("f")
j = E("j")
d = E("d")

m.o = g
g.v = c
c.w = d
c.o = m
c.q = f
f.t = d
f.v = c
j.w = g
j.q = g
j.u = c
d.w = g
d.q = g
d.u = c
assert d.w.v.q.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

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

m = A("m")
g = B("g")
c = C("c")
f = D("f")
j = E("j")
d = E("d")

m.o = g
g.v = c
c.w = d
c.o = m
c.q = f
f.t = d
f.v = c
j.w = g
j.q = g
j.u = c
d.w = g
d.q = g
d.u = c
assert d.w.v.q.t.q.txt == "g"