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

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

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

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

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

g.p = i
g.r = i
g.x = a
k.u = g
i.y = k
i.w = f
b.x = i
a.u = g
f.y = k
f.w = i
c.p = i
c.r = i
c.x = k
assert f.w.w.y.u.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: C = None
        self.x: B = None
        self.txt = txt

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

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

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

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

g.p = i
g.r = i
g.x = a
k.u = g
i.y = k
i.w = f
b.x = i
a.u = g
f.y = k
f.w = i
c.p = i
c.r = i
c.x = k
assert f.w.w.y.u.p.y.txt == "k"