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

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

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

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

m = A("m")
c = B("c")
h = C("h")
g = D("g")
d = B("d")
j = B("j")
a = B("a")
i = B("i")

m.w = h
m.x = g
c.y = i
h.s = g
h.v = d
g.v = m
g.y = m
g.o = h
d.y = i
j.y = a
a.y = i
i.y = c
assert j.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: D = None
        self.txt = txt

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

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

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

m = A("m")
c = B("c")
h = C("h")
g = D("g")
d = B("d")
j = B("j")
a = B("a")
i = B("i")

m.w = h
m.x = g
c.y = i
h.s = g
h.v = d
g.v = m
g.y = m
g.o = h
d.y = i
j.y = a
a.y = i
i.y = c
assert j.y.y.y.y.txt == "i"