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

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

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

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

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

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

g.w = b
c.y = d
k.y = m
k.q = d
k.z = g
b.x = g
m.p = g
m.r = b
d.y = c
a.y = m
a.q = d
a.z = g
l.y = d
f.p = g
f.r = b
i.p = g
i.r = b
assert f.p.w.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

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

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

g.w = b
c.y = d
k.y = m
k.q = d
k.z = g
b.x = g
m.p = g
m.r = b
d.y = c
a.y = m
a.q = d
a.z = g
l.y = d
f.p = g
f.r = b
i.p = g
i.r = b
assert f.p.w.x.w.txt == "b"