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

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

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

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

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

a.q = f
a.r = c
a.y = k
l.z = h
l.w = f
l.o = f
l.t = e
e.p = k
f.p = a
f.r = e
c.p = k
c.r = e
h.z = l
h.w = f
h.o = f
h.t = e
k.q = c
k.r = c
k.y = a
assert k.q.r.p.r.r.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.r: D = None
        self.y: A = None
        self.txt = txt

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

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

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

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

a.q = f
a.r = c
a.y = k
l.z = h
l.w = f
l.o = f
l.t = e
e.p = k
f.p = a
f.r = e
c.p = k
c.r = e
h.z = l
h.w = f
h.o = f
h.t = e
k.q = c
k.r = c
k.y = a
assert k.q.r.p.r.r.p.r.txt == "c"