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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.x: D = None
        self.p: A = None
        self.o: C = 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.t: C = None
        self.u: B = None
        self.txt = txt

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

a.u = j
a.y = j
a.q = g
j.s = a
j.p = a
j.x = l
j.o = b
b.p = a
g.t = b
g.u = j
l.t = b
l.u = j
assert b.p.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: D = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.x: D = None
        self.p: A = None
        self.o: C = 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.t: C = None
        self.u: B = None
        self.txt = txt

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

a.u = j
a.y = j
a.q = g
j.s = a
j.p = a
j.x = l
j.o = b
b.p = a
g.t = b
g.u = j
l.t = b
l.u = j
assert b.p.y.x.txt == "l"