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

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

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

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

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

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

i.y = d
i.o = f
g.z = j
g.q = j
g.o = h
f.u = h
f.x = k
k.r = j
h.v = d
h.z = f
d.v = h
d.z = f
j.z = g
j.q = g
j.o = h
assert k.r.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.o: C = None
        self.txt = txt

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

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

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

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

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

i.y = d
i.o = f
g.z = j
g.q = j
g.o = h
f.u = h
f.x = k
k.r = j
h.v = d
h.z = f
d.v = h
d.z = f
j.z = g
j.q = g
j.o = h
assert k.r.o.z.txt == "f"