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

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

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

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

b = A("b")
f = B("f")
h = C("h")
i = D("i")
j = B("j")
e = A("e")
c = B("c")

b.v = i
b.x = e
f.r = i
f.y = i
f.s = b
h.v = f
h.x = i
h.q = b
h.u = b
i.p = h
i.x = h
j.r = i
j.y = i
j.s = b
e.v = i
e.x = b
c.r = i
c.y = i
c.s = e
assert i.p.x.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.x: A = None
        self.txt = txt

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

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

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

b = A("b")
f = B("f")
h = C("h")
i = D("i")
j = B("j")
e = A("e")
c = B("c")

b.v = i
b.x = e
f.r = i
f.y = i
f.s = b
h.v = f
h.x = i
h.q = b
h.u = b
i.p = h
i.x = h
j.r = i
j.y = i
j.s = b
e.v = i
e.x = b
c.r = i
c.y = i
c.s = e
assert i.p.x.x.v.txt == "f"