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

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: F = None
        self.s: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: F = None
        self.txt = txt

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

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

f = A("f")
c = B("c")
k = C("k")
h = D("h")
n = E("n")
e = F("e")
j = B("j")
g = E("g")
l = A("l")
d = A("d")

f.v = e
c.u = j
c.y = l
c.z = f
k.y = h
k.w = e
k.s = j
h.w = e
n.t = g
e.x = d
e.r = f
j.u = c
j.y = f
j.z = l
g.t = n
l.v = e
d.v = e
assert d.v.r.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: F = None
        self.s: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: F = None
        self.txt = txt

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

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

f = A("f")
c = B("c")
k = C("k")
h = D("h")
n = E("n")
e = F("e")
j = B("j")
g = E("g")
l = A("l")
d = A("d")

f.v = e
c.u = j
c.y = l
c.z = f
k.y = h
k.w = e
k.s = j
h.w = e
n.t = g
e.x = d
e.r = f
j.u = c
j.y = f
j.z = l
g.t = n
l.v = e
d.v = e
assert d.v.r.v.r.txt == "f"