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

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.y: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: E = None
        self.p: C = None
        self.s: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

j = A("j")
c = B("c")
d = C("d")
h = D("h")
g = E("g")

j.p = d
c.v = d
d.z = g
d.y = j
h.w = d
h.p = d
h.y = g
h.s = c
g.u = j
assert d.z.u.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.y: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: E = None
        self.p: C = None
        self.s: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

j = A("j")
c = B("c")
d = C("d")
h = D("h")
g = E("g")

j.p = d
c.v = d
d.z = g
d.y = j
h.w = d
h.p = d
h.y = g
h.s = c
g.u = j
assert d.z.u.p.y.txt == "j"