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

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

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

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

h = A("h")
j = B("j")
e = C("e")
l = D("l")
b = D("b")
g = D("g")
k = C("k")

h.w = l
h.x = j
h.p = e
j.v = h
j.r = h
j.s = h
e.p = h
e.x = l
l.x = h
l.w = j
b.x = h
b.w = j
g.x = h
g.w = j
k.p = h
k.x = l
assert j.s.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.x: B = None
        self.p: C = None
        self.txt = txt

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

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

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

h = A("h")
j = B("j")
e = C("e")
l = D("l")
b = D("b")
g = D("g")
k = C("k")

h.w = l
h.x = j
h.p = e
j.v = h
j.r = h
j.s = h
e.p = h
e.x = l
l.x = h
l.w = j
b.x = h
b.w = j
g.x = h
g.w = j
k.p = h
k.x = l
assert j.s.x.s.txt == "h"