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

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

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

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

a = A("a")
m = B("m")
h = C("h")
c = D("c")
k = A("k")
i = B("i")
g = C("g")

a.w = c
a.x = k
m.v = c
h.o = c
c.v = k
c.r = a
c.o = m
c.p = i
k.w = c
k.x = a
i.v = c
g.o = c
assert i.v.p.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.x: A = None
        self.txt = txt

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

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

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

a = A("a")
m = B("m")
h = C("h")
c = D("c")
k = A("k")
i = B("i")
g = C("g")

a.w = c
a.x = k
m.v = c
h.o = c
c.v = k
c.r = a
c.o = m
c.p = i
k.w = c
k.x = a
i.v = c
g.o = c
assert i.v.p.v.r.txt == "a"