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

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

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

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

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

c.o = i
c.p = e
e.x = m
e.p = m
e.r = m
e.t = h
m.v = e
m.x = e
m.r = d
h.o = b
h.z = d
h.p = j
b.x = d
b.p = d
b.r = d
b.t = g
d.v = e
d.x = b
d.r = m
g.o = b
g.z = d
g.p = j
j.o = d
j.p = e
i.v = e
i.x = b
i.r = d
assert e.x.x.t.p.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: B = None
        self.txt = txt

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

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

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

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

c.o = i
c.p = e
e.x = m
e.p = m
e.r = m
e.t = h
m.v = e
m.x = e
m.r = d
h.o = b
h.z = d
h.p = j
b.x = d
b.p = d
b.r = d
b.t = g
d.v = e
d.x = b
d.r = m
g.o = b
g.z = d
g.p = j
j.o = d
j.p = e
i.v = e
i.x = b
i.r = d
assert e.x.x.t.p.p.t.txt == "h"