class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.u: D = None
        self.txt = txt

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

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

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

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

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

m.s = a
m.u = a
b.o = m
b.r = f
k.u = f
k.y = f
k.v = a
a.t = m
a.s = m
g.s = f
f.s = g
assert f.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.u: D = None
        self.txt = txt

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

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

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

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

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

m.s = a
m.u = a
b.o = m
b.r = f
k.u = f
k.y = f
k.v = a
a.t = m
a.s = m
g.s = f
f.s = g
assert f.s.s.s.s.txt == "f"