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

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

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

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

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

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

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

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

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

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

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