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

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

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

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

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

a.p = c
c.y = k
l.q = a
l.o = a
l.w = k
l.x = k
i.t = k
i.q = j
i.x = c
j.p = c
k.t = i
k.q = j
k.x = c
assert i.x.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

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

a.p = c
c.y = k
l.q = a
l.o = a
l.w = k
l.x = k
i.t = k
i.q = j
i.x = c
j.p = c
k.t = i
k.q = j
k.x = c
assert i.x.y.x.txt == "c"