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

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

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

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

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

i.x = e
l.p = h
l.x = j
e.s = l
e.z = l
j.p = e
j.o = e
j.r = i
j.t = h
h.x = e
assert j.r.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

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

i.x = e
l.p = h
l.x = j
e.s = l
e.z = l
j.p = e
j.o = e
j.r = i
j.t = h
h.x = e
assert j.r.x.z.txt == "l"