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

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

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

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

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

i.w = b
j.r = g
j.s = g
f.z = k
f.y = j
f.q = j
f.t = l
a.r = g
a.y = k
k.r = g
k.y = a
b.w = i
g.r = j
g.s = j
l.z = a
l.y = j
l.t = f
l.q = g
assert f.z.y.r.s.r.r.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

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

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

i.w = b
j.r = g
j.s = g
f.z = k
f.y = j
f.q = j
f.t = l
a.r = g
a.y = k
k.r = g
k.y = a
b.w = i
g.r = j
g.s = j
l.z = a
l.y = j
l.t = f
l.q = g
assert f.z.y.r.s.r.r.s.r.txt == "j"