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

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

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

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

h = A("h")
c = B("c")
j = C("j")
b = D("b")
m = D("m")
i = B("i")
a = A("a")
e = C("e")

h.y = a
h.o = i
c.r = m
c.z = i
c.w = e
j.v = c
j.o = h
b.x = h
m.x = a
i.r = m
i.z = c
i.w = e
a.y = h
a.o = i
e.v = c
e.o = h
assert i.r.x.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: B = None
        self.txt = txt

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

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

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

h = A("h")
c = B("c")
j = C("j")
b = D("b")
m = D("m")
i = B("i")
a = A("a")
e = C("e")

h.y = a
h.o = i
c.r = m
c.z = i
c.w = e
j.v = c
j.o = h
b.x = h
m.x = a
i.r = m
i.z = c
i.w = e
a.y = h
a.o = i
e.v = c
e.o = h
assert i.r.x.y.y.y.y.txt == "a"