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

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

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

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

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

l.y = b
l.p = b
l.s = a
e.u = b
h.v = e
a.o = h
a.t = l
a.x = e
b.y = l
b.p = l
b.s = a
assert e.u.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: A = None
        self.s: D = None
        self.txt = txt

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

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

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

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

l.y = b
l.p = b
l.s = a
e.u = b
h.v = e
a.o = h
a.t = l
a.x = e
b.y = l
b.p = l
b.s = a
assert e.u.s.x.txt == "e"