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

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

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

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

f = A("f")
a = B("a")
j = C("j")
g = D("g")
e = D("e")
c = B("c")
b = C("b")
i = A("i")
n = C("n")

f.v = n
f.q = i
f.s = i
f.r = c
a.x = j
a.r = g
j.v = c
j.x = n
g.x = c
g.y = a
e.x = a
e.y = c
c.x = j
c.r = g
b.v = a
b.x = n
i.v = b
i.q = f
i.s = f
i.r = a
n.v = a
n.x = j
assert j.x.x.x.v.x.v.r.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.q: A = None
        self.s: A = None
        self.r: B = None
        self.txt = txt

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

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

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

f = A("f")
a = B("a")
j = C("j")
g = D("g")
e = D("e")
c = B("c")
b = C("b")
i = A("i")
n = C("n")

f.v = n
f.q = i
f.s = i
f.r = c
a.x = j
a.r = g
j.v = c
j.x = n
g.x = c
g.y = a
e.x = a
e.y = c
c.x = j
c.r = g
b.v = a
b.x = n
i.v = b
i.q = f
i.s = f
i.r = a
n.v = a
n.x = j
assert j.x.x.x.v.x.v.r.y.x.txt == "j"