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

class B:
    def __init__(self, txt: str):
        self.w: E = None
        self.p: D = None
        self.t: C = None
        self.u: A = None
        self.txt = txt

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

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

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

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

a.v = g
a.t = c
a.o = m
c.w = m
c.p = f
c.t = g
c.u = a
g.p = f
f.v = a
f.q = c
f.y = g
m.v = a
assert f.v.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.t: B = None
        self.o: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: E = None
        self.p: D = None
        self.t: C = None
        self.u: A = None
        self.txt = txt

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

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

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

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

a.v = g
a.t = c
a.o = m
c.w = m
c.p = f
c.t = g
c.u = a
g.p = f
f.v = a
f.q = c
f.y = g
m.v = a
assert f.v.t.p.txt == "f"