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

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

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

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

g = A("g")
d = B("d")
k = C("k")
b = D("b")
e = B("e")
h = D("h")
f = C("f")

g.v = e
d.u = f
d.t = f
d.p = f
k.x = e
b.r = f
b.v = g
b.t = g
e.u = k
e.t = f
e.p = f
h.r = k
h.v = g
h.t = g
f.x = d
assert e.p.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

g = A("g")
d = B("d")
k = C("k")
b = D("b")
e = B("e")
h = D("h")
f = C("f")

g.v = e
d.u = f
d.t = f
d.p = f
k.x = e
b.r = f
b.v = g
b.t = g
e.u = k
e.t = f
e.p = f
h.r = k
h.v = g
h.t = g
f.x = d
assert e.p.x.t.txt == "f"