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

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

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

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

h = A("h")
b = B("b")
d = C("d")
c = D("c")
g = A("g")

h.o = g
h.s = b
h.z = d
b.w = d
d.v = c
d.x = c
d.w = g
d.y = g
c.x = b
g.o = h
g.s = b
g.z = d
assert h.s.w.y.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.s: B = None
        self.z: C = None
        self.txt = txt

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

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

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

h = A("h")
b = B("b")
d = C("d")
c = D("c")
g = A("g")

h.o = g
h.s = b
h.z = d
b.w = d
d.v = c
d.x = c
d.w = g
d.y = g
c.x = b
g.o = h
g.s = b
g.z = d
assert h.s.w.y.z.v.txt == "c"