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

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

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

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

m = A("m")
b = B("b")
c = C("c")
e = D("e")
f = B("f")
g = A("g")

m.z = b
m.o = e
m.y = c
b.v = g
c.u = e
e.q = b
e.s = b
e.r = g
f.v = m
g.z = b
g.o = e
g.y = c
assert g.o.s.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.o: D = None
        self.y: C = None
        self.txt = txt

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

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

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

m = A("m")
b = B("b")
c = C("c")
e = D("e")
f = B("f")
g = A("g")

m.z = b
m.o = e
m.y = c
b.v = g
c.u = e
e.q = b
e.s = b
e.r = g
f.v = m
g.z = b
g.o = e
g.y = c
assert g.o.s.v.z.v.txt == "g"