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

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.r: D = None
        self.x: A = None
        self.v: 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.y: C = None
        self.u: B = None
        self.txt = txt

k = A("k")
c = B("c")
g = C("g")
f = D("f")

k.w = f
k.r = c
c.o = f
c.r = f
c.x = k
c.v = g
g.p = c
f.y = g
f.u = c
assert c.v.p.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.r: D = None
        self.x: A = None
        self.v: 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.y: C = None
        self.u: B = None
        self.txt = txt

k = A("k")
c = B("c")
g = C("g")
f = D("f")

k.w = f
k.r = c
c.o = f
c.r = f
c.x = k
c.v = g
g.p = c
f.y = g
f.u = c
assert c.v.p.x.w.txt == "f"