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

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

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

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

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

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

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

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

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

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

a.u = i
a.p = i
a.y = j
j.p = d
j.y = l
l.o = i
l.v = g
l.t = g
l.q = j
d.y = g
d.x = g
d.r = i
i.u = a
i.y = j
i.p = g
g.u = i
g.y = j
g.p = a
assert j.y.o.y.txt == "j"