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

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

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

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

i = A("i")
j = B("j")
g = C("g")
e = D("e")
h = A("h")

i.o = h
i.p = h
i.t = e
j.z = h
g.t = e
g.o = j
g.y = h
e.x = i
h.o = i
h.p = i
h.t = e
assert j.z.t.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.p: A = None
        self.t: D = None
        self.txt = txt

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

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

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

i = A("i")
j = B("j")
g = C("g")
e = D("e")
h = A("h")

i.o = h
i.p = h
i.t = e
j.z = h
g.t = e
g.o = j
g.y = h
e.x = i
h.o = i
h.p = i
h.t = e
assert j.z.t.x.p.txt == "h"