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

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

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

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

g = A("g")
c = B("c")
l = C("l")
i = D("i")
j = D("j")
f = A("f")
m = C("m")
b = B("b")

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

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

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

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

g = A("g")
c = B("c")
l = C("l")
i = D("i")
j = D("j")
f = A("f")
m = C("m")
b = B("b")

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