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

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

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

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

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

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

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

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

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

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

f.r = k
f.t = c
f.p = c
c.x = k
g.y = c
k.u = g
assert k.u.y.x.txt == "k"