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

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

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

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

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

i = A("i")
g = B("g")
h = C("h")
k = D("k")
n = E("n")
l = C("l")
b = B("b")

i.z = b
g.t = i
g.y = b
h.y = b
k.y = n
k.s = b
k.w = i
n.t = g
n.p = k
l.y = b
b.t = i
b.y = g
assert l.y.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

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

i = A("i")
g = B("g")
h = C("h")
k = D("k")
n = E("n")
l = C("l")
b = B("b")

i.z = b
g.t = i
g.y = b
h.y = b
k.y = n
k.s = b
k.w = i
n.t = g
n.p = k
l.y = b
b.t = i
b.y = g
assert l.y.t.z.txt == "b"