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

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

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

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

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

c.w = h
c.z = l
c.r = l
c.t = d
l.v = g
d.s = g
d.p = h
d.x = l
g.y = l
g.z = l
g.v = d
h.w = c
h.z = l
h.r = l
h.t = d
assert h.t.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.z: B = None
        self.r: B = None
        self.t: C = None
        self.txt = txt

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

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

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

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

c.w = h
c.z = l
c.r = l
c.t = d
l.v = g
d.s = g
d.p = h
d.x = l
g.y = l
g.z = l
g.v = d
h.w = c
h.z = l
h.r = l
h.t = d
assert h.t.p.r.txt == "l"