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

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

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

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

j = A("j")
g = B("g")
f = C("f")
m = D("m")
i = B("i")

j.y = g
g.p = f
g.w = f
g.x = i
g.s = j
f.x = j
f.t = g
m.t = j
m.v = f
i.p = f
i.w = f
i.x = g
i.s = j
assert i.x.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

j = A("j")
g = B("g")
f = C("f")
m = D("m")
i = B("i")

j.y = g
g.p = f
g.w = f
g.x = i
g.s = j
f.x = j
f.t = g
m.t = j
m.v = f
i.p = f
i.w = f
i.x = g
i.s = j
assert i.x.p.t.txt == "g"