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

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

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

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

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

i.o = c
i.s = c
i.q = g
i.p = j
l.x = g
l.w = g
l.s = g
l.y = i
g.r = l
j.x = g
j.p = g
j.r = l
c.o = i
c.s = i
c.q = g
c.p = j
assert i.s.s.q.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: C = None
        self.s: A = None
        self.p: D = None
        self.txt = txt

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

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

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

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

i.o = c
i.s = c
i.q = g
i.p = j
l.x = g
l.w = g
l.s = g
l.y = i
g.r = l
j.x = g
j.p = g
j.r = l
c.o = i
c.s = i
c.q = g
c.p = j
assert i.s.s.q.r.y.txt == "i"