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

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

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

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

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

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

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

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

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

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

g.t = i
g.x = h
g.y = h
g.v = d
h.w = m
h.s = i
h.z = i
h.o = l
m.o = l
m.r = l
l.z = m
l.p = m
l.q = h
l.o = i
i.t = g
i.v = g
i.x = h
i.y = h
d.t = g
d.x = h
d.y = h
d.v = i
assert i.t.v.v.v.v.t.txt == "g"