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

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

g = A("g")
f = B("f")
h = C("h")
a = D("a")
e = E("e")
n = F("n")
j = D("j")

g.r = n
g.s = h
f.w = h
f.r = j
f.x = a
h.o = j
h.r = a
a.v = f
e.s = h
n.x = e
j.v = f
assert f.r.v.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: F = None
        self.s: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

g = A("g")
f = B("f")
h = C("h")
a = D("a")
e = E("e")
n = F("n")
j = D("j")

g.r = n
g.s = h
f.w = h
f.r = j
f.x = a
h.o = j
h.r = a
a.v = f
e.s = h
n.x = e
j.v = f
assert f.r.v.x.v.txt == "f"