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

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

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

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

e = A("e")
b = B("b")
h = C("h")
l = D("l")

e.o = b
e.q = h
e.v = h
b.s = h
h.o = e
h.q = b
l.o = h
l.z = b
l.y = b
l.s = e
assert l.o.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: C = None
        self.v: C = None
        self.txt = txt

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

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

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

e = A("e")
b = B("b")
h = C("h")
l = D("l")

e.o = b
e.q = h
e.v = h
b.s = h
h.o = e
h.q = b
l.o = h
l.z = b
l.y = b
l.s = e
assert l.o.q.s.txt == "h"