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

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

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

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

g = A("g")
b = B("b")
a = C("a")
f = D("f")
l = A("l")
m = A("m")

g.u = b
g.v = f
g.s = f
b.t = m
a.z = m
a.v = f
a.r = f
a.w = l
f.v = a
f.q = a
f.z = l
l.u = b
l.v = f
l.s = f
m.u = b
m.v = f
m.s = f
assert f.z.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: D = None
        self.s: D = None
        self.txt = txt

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

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

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

g = A("g")
b = B("b")
a = C("a")
f = D("f")
l = A("l")
m = A("m")

g.u = b
g.v = f
g.s = f
b.t = m
a.z = m
a.v = f
a.r = f
a.w = l
f.v = a
f.q = a
f.z = l
l.u = b
l.v = f
l.s = f
m.u = b
m.v = f
m.s = f
assert f.z.v.v.txt == "a"