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

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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

l.w = n
l.o = n
l.y = c
b.q = l
n.o = b
a.v = c
a.x = n
j.v = c
j.x = n
c.v = a
c.x = n
assert c.v.x.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: D = None
        self.o: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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

l.w = n
l.o = n
l.y = c
b.q = l
n.o = b
a.v = c
a.x = n
j.v = c
j.x = n
c.v = a
c.x = n
assert c.v.x.o.q.txt == "l"