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

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

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

c.w = l
c.t = k
i.x = k
i.v = c
k.p = i
b.t = i
b.w = l
g.t = i
g.w = l
l.w = c
l.t = k
assert b.t.x.p.x.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.t: C = None
        self.txt = txt

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

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

c.w = l
c.t = k
i.x = k
i.v = c
k.p = i
b.t = i
b.w = l
g.t = i
g.w = l
l.w = c
l.t = k
assert b.t.x.p.x.p.v.txt == "c"