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

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

class C:
    def __init__(self, txt: str):
        self.z: A = None
        self.y: D = None
        self.v: D = None
        self.s: B = None
        self.r: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: B = None
        self.p: C = None
        self.s: C = None
        self.x: A = None
        self.z: D = None
        self.txt = txt

a = A("a")
h = B("h")
l = C("l")
d = D("d")
f = E("f")
g = C("g")

a.t = h
a.u = d
a.r = d
h.x = d
h.t = d
h.v = a
l.z = a
l.y = d
l.v = d
l.s = h
l.r = h
d.v = a
d.u = a
f.r = h
f.p = g
f.s = g
f.x = a
f.z = d
g.z = a
g.y = d
g.v = d
g.s = h
g.r = h
assert h.t.v.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.u: D = None
        self.r: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: A = None
        self.y: D = None
        self.v: D = None
        self.s: B = None
        self.r: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: B = None
        self.p: C = None
        self.s: C = None
        self.x: A = None
        self.z: D = None
        self.txt = txt

a = A("a")
h = B("h")
l = C("l")
d = D("d")
f = E("f")
g = C("g")

a.t = h
a.u = d
a.r = d
h.x = d
h.t = d
h.v = a
l.z = a
l.y = d
l.v = d
l.s = h
l.r = h
d.v = a
d.u = a
f.r = h
f.p = g
f.s = g
f.x = a
f.z = d
g.z = a
g.y = d
g.v = d
g.s = h
g.r = h
assert h.t.v.t.t.txt == "d"