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

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

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

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

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

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

h.z = d
h.s = b
f.r = d
f.t = b
j.v = i
j.x = d
j.w = d
j.y = d
c.x = k
d.z = c
k.v = i
k.x = d
k.w = d
k.y = d
i.z = d
i.s = h
b.z = d
b.s = h
assert d.z.x.y.z.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.s: A = None
        self.txt = txt

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

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

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

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

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

h.z = d
h.s = b
f.r = d
f.t = b
j.v = i
j.x = d
j.w = d
j.y = d
c.x = k
d.z = c
k.v = i
k.x = d
k.w = d
k.y = d
i.z = d
i.s = h
b.z = d
b.s = h
assert d.z.x.y.z.x.x.txt == "d"