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

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

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

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

c = A("c")
b = B("b")
m = C("m")
a = D("a")
j = D("j")
d = A("d")
f = B("f")

c.q = d
c.t = f
c.w = m
b.v = a
b.x = f
m.s = j
m.z = b
a.s = d
a.o = b
j.s = d
j.o = f
d.q = c
d.t = f
d.w = m
f.v = j
f.x = b
assert f.x.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: B = None
        self.w: C = None
        self.txt = txt

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

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

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

c = A("c")
b = B("b")
m = C("m")
a = D("a")
j = D("j")
d = A("d")
f = B("f")

c.q = d
c.t = f
c.w = m
b.v = a
b.x = f
m.s = j
m.z = b
a.s = d
a.o = b
j.s = d
j.o = f
d.q = c
d.t = f
d.w = m
f.v = j
f.x = b
assert f.x.v.s.txt == "d"