class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: A = None
        self.r: C = None
        self.txt = txt

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

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

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

e = A("e")
c = B("c")
h = C("h")
a = D("a")
f = C("f")
l = A("l")

e.y = a
e.q = l
e.r = h
c.w = a
c.x = f
c.r = f
h.y = a
a.r = c
a.w = l
a.v = h
f.y = a
l.y = a
l.q = e
l.r = h
assert l.q.q.y.r.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: A = None
        self.r: C = None
        self.txt = txt

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

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

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

e = A("e")
c = B("c")
h = C("h")
a = D("a")
f = C("f")
l = A("l")

e.y = a
e.q = l
e.r = h
c.w = a
c.x = f
c.r = f
h.y = a
a.r = c
a.w = l
a.v = h
f.y = a
l.y = a
l.q = e
l.r = h
assert l.q.q.y.r.w.v.txt == "h"