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

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

class C:
    def __init__(self, txt: str):
        self.o: E = None
        self.q: B = None
        self.r: D = None
        self.w: B = None
        self.txt = txt

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

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

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

f.y = j
g.w = n
g.x = n
n.o = d
n.q = g
n.w = g
n.r = j
j.o = n
j.z = i
j.t = f
d.x = i
d.t = g
i.x = d
i.t = g
assert g.w.o.t.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: E = None
        self.q: B = None
        self.r: D = None
        self.w: B = None
        self.txt = txt

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

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

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

f.y = j
g.w = n
g.x = n
n.o = d
n.q = g
n.w = g
n.r = j
j.o = n
j.z = i
j.t = f
d.x = i
d.t = g
i.x = d
i.t = g
assert g.w.o.t.w.o.txt == "d"