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

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

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

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

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

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

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

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

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

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

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

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

f.v = i
f.r = e
d.y = k
d.w = e
d.x = g
k.y = h
k.x = i
k.r = e
h.q = k
h.z = c
g.v = h
g.r = h
g.x = d
g.z = d
e.v = i
e.r = f
i.v = c
i.r = h
i.x = d
i.z = d
c.q = k
c.z = h
assert g.x.y.r.txt == "e"