class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: F = None
        self.w: D = None
        self.s: A = None
        self.r: C = None
        self.v: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

g = A("g")
f = B("f")
d = C("d")
e = D("e")
i = E("i")
h = F("h")
j = C("j")

g.u = h
g.y = f
f.r = i
d.r = h
d.z = g
d.v = f
e.x = g
i.z = h
i.w = e
i.s = g
i.r = j
i.v = j
h.p = i
j.r = h
j.z = g
j.v = f
assert f.r.w.x.y.r.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: F = None
        self.w: D = None
        self.s: A = None
        self.r: C = None
        self.v: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

g = A("g")
f = B("f")
d = C("d")
e = D("e")
i = E("i")
h = F("h")
j = C("j")

g.u = h
g.y = f
f.r = i
d.r = h
d.z = g
d.v = f
e.x = g
i.z = h
i.w = e
i.s = g
i.r = j
i.v = j
h.p = i
j.r = h
j.z = g
j.v = f
assert f.r.w.x.y.r.z.p.txt == "i"