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

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

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

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

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

j.o = h
a.w = h
h.r = j
h.q = c
c.o = j
c.s = j
c.v = h
c.y = l
l.w = h
assert c.y.w.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

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

j.o = h
a.w = h
h.r = j
h.q = c
c.o = j
c.s = j
c.v = h
c.y = l
l.w = h
assert c.y.w.r.o.txt == "h"