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

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

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

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

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

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

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

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

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

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

b.p = h
b.v = g
b.r = n
b.q = n
g.x = b
f.q = b
f.w = n
f.y = n
n.o = k
n.w = h
n.u = b
n.y = f
k.o = n
k.w = g
k.u = b
k.y = f
h.x = b
assert f.q.v.x.txt == "b"