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

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.w: C = None
        self.q: C = None
        self.v: A = 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: A = None
        self.y: B = None
        self.txt = txt

a = A("a")
c = B("c")
l = C("l")
h = D("h")
g = A("g")

a.o = g
a.y = l
a.z = h
a.x = c
c.s = h
c.w = l
c.q = l
c.v = g
l.p = a
h.t = g
h.y = c
g.o = a
g.y = l
g.z = h
g.x = c
assert h.t.o.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: C = None
        self.z: D = None
        self.x: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.w: C = None
        self.q: C = None
        self.v: A = 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: A = None
        self.y: B = None
        self.txt = txt

a = A("a")
c = B("c")
l = C("l")
h = D("h")
g = A("g")

a.o = g
a.y = l
a.z = h
a.x = c
c.s = h
c.w = l
c.q = l
c.v = g
l.p = a
h.t = g
h.y = c
g.o = a
g.y = l
g.z = h
g.x = c
assert h.t.o.y.p.txt == "a"