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

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

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

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

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

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

c.o = n
c.u = f
h.o = d
h.w = d
h.r = c
h.t = c
h.y = f
d.w = h
f.s = c
m.r = d
n.o = c
n.u = f
assert c.u.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: D = None
        self.txt = txt

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

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

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

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

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

c.o = n
c.u = f
h.o = d
h.w = d
h.r = c
h.t = c
h.y = f
d.w = h
f.s = c
m.r = d
n.o = c
n.u = f
assert c.u.s.u.txt == "f"