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

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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