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

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

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

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

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

g = A("g")
d = B("d")
b = C("b")
n = D("n")
m = E("m")
f = D("f")
j = B("j")
k = B("k")
c = C("c")
l = A("l")

g.z = b
g.o = l
d.w = b
b.s = d
b.z = j
b.p = g
n.y = g
n.q = g
m.x = l
m.z = d
m.v = b
m.r = g
f.y = l
f.q = l
j.w = b
k.w = b
c.s = d
c.z = j
c.p = g
l.z = c
l.o = g
assert m.z.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.o: A = None
        self.txt = txt

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

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

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

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

g = A("g")
d = B("d")
b = C("b")
n = D("n")
m = E("m")
f = D("f")
j = B("j")
k = B("k")
c = C("c")
l = A("l")

g.z = b
g.o = l
d.w = b
b.s = d
b.z = j
b.p = g
n.y = g
n.q = g
m.x = l
m.z = d
m.v = b
m.r = g
f.y = l
f.q = l
j.w = b
k.w = b
c.s = d
c.z = j
c.p = g
l.z = c
l.o = g
assert m.z.w.z.txt == "j"