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

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

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

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

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

a = A("a")
g = B("g")
d = C("d")
b = D("b")
k = E("k")
h = A("h")

a.x = b
a.u = d
a.w = h
g.s = h
g.t = d
d.p = g
b.r = k
b.v = d
b.y = d
k.x = b
h.x = b
h.u = d
h.w = a
assert k.x.y.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: C = None
        self.w: A = None
        self.txt = txt

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

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

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

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

a = A("a")
g = B("g")
d = C("d")
b = D("b")
k = E("k")
h = A("h")

a.x = b
a.u = d
a.w = h
g.s = h
g.t = d
d.p = g
b.r = k
b.v = d
b.y = d
k.x = b
h.x = b
h.u = d
h.w = a
assert k.x.y.p.s.txt == "h"