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

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: D = None
        self.s: E = None
        self.v: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: D = None
        self.p: D = None
        self.w: A = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: D = None
        self.s: E = None
        self.v: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: D = None
        self.p: D = None
        self.w: A = None
        self.txt = txt

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

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

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

g.v = d
g.u = i
k.y = f
k.u = f
k.s = b
k.v = d
c.t = k
c.s = f
c.p = f
c.w = i
f.v = g
d.v = c
d.t = c
d.x = k
b.v = c
b.t = c
b.x = k
i.v = d
i.u = g
assert f.v.v.t.w.v.txt == "d"