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

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

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

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

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

j.t = h
j.o = d
i.s = a
f.q = d
f.x = c
f.z = i
h.p = i
h.z = d
h.v = m
d.p = i
d.z = l
d.v = m
a.s = i
m.t = l
m.o = h
c.q = h
c.x = f
c.z = a
l.p = a
l.z = d
l.v = m
g.t = h
g.o = h
assert m.t.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.o: D = None
        self.txt = txt

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

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

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

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

j.t = h
j.o = d
i.s = a
f.q = d
f.x = c
f.z = i
h.p = i
h.z = d
h.v = m
d.p = i
d.z = l
d.v = m
a.s = i
m.t = l
m.o = h
c.q = h
c.x = f
c.z = a
l.p = a
l.z = d
l.v = m
g.t = h
g.o = h
assert m.t.z.p.txt == "i"