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

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

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

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

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

i.x = m
i.w = a
i.s = f
g.x = i
g.s = k
g.y = d
g.w = a
m.s = d
a.t = b
a.q = i
b.x = m
b.s = m
b.w = a
j.s = g
k.x = i
k.s = d
k.y = d
k.w = a
d.x = i
d.s = k
d.y = k
d.w = a
f.s = g
assert b.s.s.y.y.y.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.w: D = None
        self.s: C = None
        self.txt = txt

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

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

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

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

i.x = m
i.w = a
i.s = f
g.x = i
g.s = k
g.y = d
g.w = a
m.s = d
a.t = b
a.q = i
b.x = m
b.s = m
b.w = a
j.s = g
k.x = i
k.s = d
k.y = d
k.w = a
d.x = i
d.s = k
d.y = k
d.w = a
f.s = g
assert b.s.s.y.y.y.x.x.txt == "m"