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

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

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

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

c = A("c")
j = B("j")
h = C("h")
n = D("n")
g = B("g")
f = C("f")

c.v = f
j.x = f
j.u = g
h.x = c
n.v = c
n.r = j
n.t = j
n.p = g
g.x = h
g.u = j
f.x = c
assert f.x.v.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

c = A("c")
j = B("j")
h = C("h")
n = D("n")
g = B("g")
f = C("f")

c.v = f
j.x = f
j.u = g
h.x = c
n.v = c
n.r = j
n.t = j
n.p = g
g.x = h
g.u = j
f.x = c
assert f.x.v.x.v.txt == "f"