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

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

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

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

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

b.s = g
d.z = c
d.s = c
d.r = m
d.w = h
m.v = b
k.v = f
k.x = d
k.z = m
j.v = k
j.x = c
j.z = m
c.z = d
c.s = d
c.r = m
c.w = b
h.s = b
g.s = h
f.v = k
f.x = c
f.z = m
assert d.r.v.s.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

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

b.s = g
d.z = c
d.s = c
d.r = m
d.w = h
m.v = b
k.v = f
k.x = d
k.z = m
j.v = k
j.x = c
j.z = m
c.z = d
c.s = d
c.r = m
c.w = b
h.s = b
g.s = h
f.v = k
f.x = c
f.z = m
assert d.r.v.s.s.s.s.s.s.s.txt == "g"