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

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

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

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

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

g.x = m
g.o = f
m.v = l
m.x = c
f.z = g
f.w = l
f.p = m
a.s = i
a.t = i
a.r = g
a.o = g
l.v = m
l.x = g
c.x = m
c.o = f
i.s = a
i.t = a
i.r = g
i.o = c
assert f.p.v.x.o.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.o: C = None
        self.txt = txt

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

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

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

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

g.x = m
g.o = f
m.v = l
m.x = c
f.z = g
f.w = l
f.p = m
a.s = i
a.t = i
a.r = g
a.o = g
l.v = m
l.x = g
c.x = m
c.o = f
i.s = a
i.t = a
i.r = g
i.o = c
assert f.p.v.x.o.w.x.txt == "g"