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

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: D = None
        self.p: A = None
        self.y: C = None
        self.txt = txt

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

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

e.r = a
a.t = f
a.y = f
a.r = m
c.o = a
c.u = f
c.p = e
c.y = m
f.y = m
m.o = a
m.u = f
m.p = e
m.y = c
assert a.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: D = None
        self.p: A = None
        self.y: C = None
        self.txt = txt

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

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

e.r = a
a.t = f
a.y = f
a.r = m
c.o = a
c.u = f
c.p = e
c.y = m
f.y = m
m.o = a
m.u = f
m.p = e
m.y = c
assert a.y.y.y.y.y.txt == "c"