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

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

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

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

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

d = A("d")
a = B("a")
f = C("f")
i = D("i")
k = E("k")
h = D("h")

d.r = f
d.o = f
d.y = f
a.o = d
a.y = d
f.x = h
i.u = f
i.x = f
i.w = d
k.x = d
h.u = f
h.x = f
h.w = d
assert a.y.y.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: C = None
        self.y: C = None
        self.txt = txt

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

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

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

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

d = A("d")
a = B("a")
f = C("f")
i = D("i")
k = E("k")
h = D("h")

d.r = f
d.o = f
d.y = f
a.o = d
a.y = d
f.x = h
i.u = f
i.x = f
i.w = d
k.x = d
h.u = f
h.x = f
h.w = d
assert a.y.y.x.x.x.txt == "h"