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

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

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

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

h = A("h")
i = B("i")
m = C("m")
g = D("g")
d = A("d")
f = C("f")

h.t = i
h.x = i
h.v = i
h.w = d
i.x = m
m.o = g
g.s = d
g.z = m
g.x = h
d.t = i
d.x = i
d.v = i
d.w = h
f.o = g
assert i.x.o.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.w: A = None
        self.x: B = None
        self.v: B = None
        self.txt = txt

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

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

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

h = A("h")
i = B("i")
m = C("m")
g = D("g")
d = A("d")
f = C("f")

h.t = i
h.x = i
h.v = i
h.w = d
i.x = m
m.o = g
g.s = d
g.z = m
g.x = h
d.t = i
d.x = i
d.v = i
d.w = h
f.o = g
assert i.x.o.z.o.txt == "g"