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

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

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: A = None
        self.s: D = None
        self.r: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

f = A("f")
c = B("c")
l = C("l")
m = D("m")
h = E("h")

f.t = c
f.o = h
c.r = h
c.v = m
l.t = f
l.q = f
l.s = m
l.r = c
m.t = c
h.v = m
assert m.t.v.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.o: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: A = None
        self.s: D = None
        self.r: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

f = A("f")
c = B("c")
l = C("l")
m = D("m")
h = E("h")

f.t = c
f.o = h
c.r = h
c.v = m
l.t = f
l.q = f
l.s = m
l.r = c
m.t = c
h.v = m
assert m.t.v.t.v.txt == "m"